Skip to content

Instantly share code, notes, and snippets.

View vijinho's full-sized avatar

Vijay vijinho

  • England
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / win10backup.sh
Created September 17, 2020 20:55
Simple 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"
# Simple 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
date
echo "Saving partition map of ${PART}..."
fdisk -l /dev/${PART} > ${PART}.fdisk
cat ${PART}.fdisk
echo "Saving boot sector of ${PART}..."
dd bs=2048 count=1 if=/dev/${PART} of=${PART}.mbr
@vijinho
vijinho / fstab
Last active September 17, 2020 21:33
/etc/fstab example with different filesystems
# /etc/fstab: static file system information.
# <file system> <mount point> <type> <options> <dump> <pass>
UUID=XXXX-XXXX /boot/efi vfat umask=0077,x-gvfs-show,x-gvfs-name=EFI 0 0
UUID=XXXXX /mnt/f2fs f2fs rw,relatime,lazytime,background_gc=on,discard,no_heap,user_xattr,inline_xattr,inline_data,inline_dentry,flush_merge,extent_cache,mode=adaptive,active_logs=6,alloc_mode=default,fsync_mode=posix,background_gc=on,user_xattr,x-gvfs-show,x-gvfs-name=PopOs 0 0
UUID=XXXXX /mnt/ext4 ext4 nofail,noatime,nodiratime,discard,commit=90,max_batch_time=50022,min_batch_time=5000,journal_ioprio=0,errors=remount-ro,x-gvfs-show,x-gvfs-name=data 0 0
UUID=XXXX-XXXX /mnt/exfat exfat nofail,noatime,nodiratime,rw,allow_utime=2,nosuid,nodev,umask=0022,dmask=0022,uid=1000,gid=1000,user,x-gvfs-show,x-gvfs-name=data 0 0
UUID=XXXXXXXXXXXXXX /mnt/ntfs ntfs-3g nofail,rw,relatime,umask=0022,user_id=1000,group_id=1000,user,allow_other,big_writes,lazytime,windows_names,noatime,nodiratime,x-gvfs-show,x-gvfs-name=data2-ntfs,nosuid,nodev
@vijinho
vijinho / ext4defrag.sh
Created September 4, 2020 19:02
defrag ext4 filesystem
umount $1
fsck.ext4 -v -F -f -p -D -E inode_count_fullmap,optimize_extents, $1
mount $1
@vijinho
vijinho / ext4badblocks.sh
Created September 4, 2020 19:02
Check for bad blocks on ext4 filesystem
umount $1
fsck.ext4 -f -c -k -p -t -v -D -E inode_count_fullmap $1
mount $1
@vijinho
vijinho / markdown_escape.php
Last active September 22, 2024 22:37
Escape markdown in php
<?php
/**
* Escape markdown text
*
* @param string $text the markdown text to escape
*
* @return string escaped text
*/
function markdown_escape($text) {
return str_replace([