Skip to content

Instantly share code, notes, and snippets.

View vijinho's full-sized avatar

Vijay vijinho

  • England
View GitHub Profile
@vijinho
vijinho / ext4-check-bad-blocks.sh
Last active January 6, 2025 10:32
Unmount a given ext4 filesystem and check it for bad blocks, then remount it
#!/bin/bash
# Check if the user has provided a device or partition argument
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <device>"
exit 1
fi
DEVICE=$1
@vijinho
vijinho / ext4-defrag.sh
Last active January 6, 2025 10:35
Script to unmount, defrag and remount and ext4 filesystem
#!/bin/bash
# Check if the user has provided a device argument
if [ -z "$1" ]; then
echo "Usage: $0 <device>"
exit 1
fi
DEVICE=$1
@vijinho
vijinho / win10-backup.sh
Last active January 6, 2025 10:41
Windows 10 backup script to back up the standard windows installation on a give device - USE AT YOUR OWN RISK!!!
# Improved Windows 10 backup script to backup a Windows 10 installation (EFI or MBR) using the /dev/ name, e.g. if on sda run "sh win10backup.sh sda"
PART=$1
# Check if partition is provided
if [ -z "$PART" ]; then
echo "Error: Partition not specified"
exit 1
fi
@vijinho
vijinho / rcloned.service
Last active September 20, 2020 21:22
Simple example of running an rcloned sftpd service on ubuntu/popos. place in "/etc/systemd/system/rcloned.service" then "systemctl daemon-reload" then "systemctl enable rcloned.service" and it should be up on next reboot.
[Unit]
Description=rclone sftp service
Documentation=man:rclone(1)
After=network.target auditd.service
[Service]
ExecStart=rclone serve sftp --no-auth --addr :2022 \
--vfs-cache-mode full \
--vfs-cache-max-age 10m \
--vfs-cache-max-size 32768 \
@vijinho
vijinho / rclonedlna.service
Created September 20, 2020 22:19
Example rclone dlna startup service script on ubuntu/popos. place in "/etc/systemd/system/rclonedlna.service" then "systemctl daemon-reload" then "systemctl enable rclonedlna.service" and it should be up on next reboot.
[Unit]
Description=rclone dlna service
Documentation=man:rclone(1)
After=network.target auditd.service
[Service]
ExecStart=rclone serve dlna --addr :8080 \
--vfs-cache-mode full \
--vfs-cache-max-age 60m \
--vfs-cache-max-size 32768 \
@vijinho
vijinho / dlna.sh
Last active July 22, 2024 19:27
A simple DLNA server using rclone, run with "dlna.sh <PORT> <FOLDER>" e.g. dlna.sh 8080 /mnt/shared/music/ - can be run on boot with last line added to 'crontab -e' for root
# ./dlna.sh 8080 /mnt/data/audio
PORT=$1
DATA_DIR=$2
NAME=`basename $DATA_DIR`
CACHE_DIR=/var/cache/dlna/$NAME
#rm -fR $CACHE_DIR
mkdir -p $CACHE_DIR
chmod -fR 777 $CACHE_DIR
/home/linuxbrew/.linuxbrew/bin/rclone serve dlna --addr :$PORT $DATA_DIR --buffer-size 1G --dir-cache-time 24h --cache-dir $CACHE_DIR --vfs-cache-mode full --vfs-cache-max-size 1G --vfs-cache-max-size 16M --no-checksum --no-modtime --vfs-case-insensitive --vfs-disk-space-total-size 4G --name $NAME 2>&1 > /var/log/rclone.log &
exit 0
@vijinho
vijinho / dav-simple.sh
Last active July 22, 2024 19:26
Simple insecure local dav server using rclone - specify port and data dir, dirname used as user/pass, e.g. dav.sh 8080 /mnt/data/joplin/
# ./dav.sh 8090 /mnt/data/joplin
PORT=$1
DATA_DIR=$2
NAME=`basename $DATA_DIR`
CACHE_DIR=/var/cache/dav/$NAME
#rm -fR $CACHE_DIR
mkdir -p $CACHE_DIR
chmod -fR 777 $CACHE_DIR
/home/linuxbrew/.linuxbrew/bin/rclone serve webdav --user $NAME --pass $NAME --addr :$PORT $DATA_DIR --buffer-size 512M --dir-cache-time 15m --cache-dir $CACHE_DIR --vfs-cache-mode full --vfs-cache-max-size 4G --vfs-cache-max-size 1G --no-checksum --vfs-case-insensitive --vfs-disk-space-total-size 4G 2>&1 > /var/log/rclone.log &
exit 0
@vijinho
vijinho / dav.sh
Last active July 22, 2024 19:26
Simple dav server using rclone with a htpasswd file, specify port and data dir, designed for home network usage only. e.g. dav.sh 8080 /mnt/data/joplin - serves webdav using .htpasswd file in folder joplin - can be run from crontab using @reboot
# ./dav.sh 8090 /mnt/data/joplin
PORT=$1
DATA_DIR=$2
NAME=`basename $DATA_DIR`
CACHE_DIR=/var/cache/dav/$NAME
#rm -fR $CACHE_DIR
mkdir -p $CACHE_DIR
chmod -fR 777 $CACHE_DIR
/home/linuxbrew/.linuxbrew/bin/rclone serve webdav --htpasswd $DATA_DIR/.htpasswd --addr :$PORT $DATA_DIR --buffer-size 512M --dir-cache-time 15m --cache-dir $CACHE_DIR --vfs-cache-mode full --vfs-cache-max-size 4G --no-checksum --vfs-case-insensitive --vfs-disk-space-total-size 4G 2>&1 > /var/log/rclone.log &
exit 0
@vijinho
vijinho / whisper-wrapper.sh
Last active January 8, 2025 12:48
wrapper for https://github.com/ggerganov/whisper.cpp whisper.cpp to generate transcriptions from given input media file
#!/bin/bash
# Default values
MODEL="$HOME/src/whisper.cpp/models/ggml-large-v3-turbo-q5_0.bin"
INPUT_FILE=""
OUTPUT_FILE="$TEMP/whisper-$(date "+%Y%m%d%H%M%S").wav"
WHISPER_ARGS="-m $MODEL -l en -t 12 -pp -pc -otxt -ovtt -osrt"
# Function to display usage information
usage() {
@vijinho
vijinho / generate-subtitles.sh
Last active January 7, 2025 09:31
A bash script to check a folder for media (video/audio) files and transcribe them using 'whisper' (working) or 'whisper-clli' (TBD later) by detecting if there exists a .srt file already
#!/bin/bash
# NOTE this is actually using whisper-wrapper.sh: https://gist.github.com/vijinho/ad9bd80c990a803efef7f96ae3e7ee98
# Function to display usage information
usage() {
echo "Usage: $0 [-m | --media-directory <directory>] [-a | --transcription-args \"<arguments>\"]"
echo "Defaults: -m `pwd`"
exit 1
}