From b4f587ce1c84706bdb9d8fb8cd87ed0f702ae8ab Mon Sep 17 00:00:00 2001 From: velvettear Date: Wed, 28 Aug 2024 15:24:03 +0200 Subject: [PATCH] clean repository --- README.md | 2 +- scripts/notify.sh | 58 ---------------------------- scripts/prepare-fs.sh | 24 ------------ scripts/restic/j5040.sh | 21 ----------- scripts/restic/n100.sh | 30 --------------- scripts/restic/restic.sh | 32 ---------------- scripts/update.sh | 63 ------------------------------- scripts/zfs-scrub.sh | 18 --------- systemd/prepare-fs.service | 11 ------ systemd/restic/restic.service | 10 ----- systemd/restic/restic.timer | 8 ---- systemd/zfs/zfs-scrub.service | 9 ----- systemd/zfs/zfs-scrub.timer | 8 ---- zsh/zprofile | 71 ----------------------------------- zsh/zshrc | 8 ---- 15 files changed, 1 insertion(+), 372 deletions(-) delete mode 100755 scripts/notify.sh delete mode 100755 scripts/prepare-fs.sh delete mode 100755 scripts/restic/j5040.sh delete mode 100755 scripts/restic/n100.sh delete mode 100755 scripts/restic/restic.sh delete mode 100755 scripts/update.sh delete mode 100755 scripts/zfs-scrub.sh delete mode 100644 systemd/prepare-fs.service delete mode 100644 systemd/restic/restic.service delete mode 100644 systemd/restic/restic.timer delete mode 100644 systemd/zfs/zfs-scrub.service delete mode 100644 systemd/zfs/zfs-scrub.timer delete mode 100755 zsh/zprofile delete mode 100755 zsh/zshrc diff --git a/README.md b/README.md index 3023967..826ca45 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # .dots -### personal dot files for proxmox based hosts +### personal dot files diff --git a/scripts/notify.sh b/scripts/notify.sh deleted file mode 100755 index f3a251c..0000000 --- a/scripts/notify.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env bash - -# author: Daniel Sommer -# license: MIT - -# usage: -# notify.sh [options] -# documentation @ https://docs.ntfy.sh/publish - -url="https://notify.velvettear.de" -user="velvettear" -password="\$Velvet90" - -[[ -z "$1" ]] && printf "error: no topic specified\n" 1>&2 && exit 1 -[[ -z "$2" ]] && printf "error: no payload specified\n" 1>&2 && exit 1 - -url="$url/$1" -payload="$2" - -# check if payload is a file -if [[ -e "$payload" ]]; then - args+=("-T" "$(realpath $payload)" "-H" "Filename: $(basename $payload)") -else - args+=("-d" "$payload") -fi - -# check for valid priority level -function checkPriority() { - prio="$(printf "$1" | tr '[:upper:]' '[:lower:]')" - if [[ "$prio" == "min" ]] || [[ "$prio" == "low" ]] || [[ "$prio" == "default" ]] || [[ "$prio" == "high" ]] || [[ "$prio" == "max" ]] || [[ "$prio" == "urgent" ]]; then - args+=("-H" "Priority: $prio") - fi -} - -# check arguments -index=1 -for arg in "$@"; do - ((index++)) - value="${!index}" - case "$arg" in - -e|--emoji|-i|--icon) - args+=("-H" "Tags: $value") - ;; - -p|--priority) - checkPriority "$value" - ;; - -t|--title) - args+=("-H" "Title: $value") - ;; - esac -done - -echo "user: $user" -echo "pw: $password" -echo "url: $url" -echo "args: ${args[@]}" - -curl -u $user:$password "${args[@]}" $url diff --git a/scripts/prepare-fs.sh b/scripts/prepare-fs.sh deleted file mode 100755 index 70fa0ee..0000000 --- a/scripts/prepare-fs.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -# author: Daniel Sommer -# license: MIT - -# this script is used in a systemd service file (wanted by other services) - -[[ "$EUID" != 0 ]] && printf "error: permission denied!\n" && exit 1 - -printf "preparing filesystem...\n" - -if [[ ! -d "/var/log/pveproxy" ]]; then - printf "creating directory '/var/log/pveproxy' with owner 'www-data'...\n" - mkdir -p /var/log/pveproxy - chown -R www-data:www-data /var/log/pveproxy -fi - -if [[ ! -d "/var/log/nginx" ]]; then - printf "creating directory '/var/log/nginx' with owner 'www-data'...\n" - mkdir -p /var/log/nginx - chown -R www-data:www-data /var/log/nginx -fi - -printf "finished preparing the filesystem!\n" diff --git a/scripts/restic/j5040.sh b/scripts/restic/j5040.sh deleted file mode 100755 index 424ddbd..0000000 --- a/scripts/restic/j5040.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash - -# author: Daniel Sommer -# license: MIT - -[[ "$EUID" != 0 ]] && printf "error: permission denied!\n" >&2 && exit 1 - -directories=( - "/etc" -) - -printf ">> starting restic backup...\n" - -for directory in ${directories[@]}; do - seconds="$SECONDS" - printf "> backing up '"$directory"'...\n" - restic backup --verbose --no-scan --retry-lock 3h "$directory" - printf "> backup of '"$directory"' finished after "$(( $SECONDS - $seconds ))" seconds!\n" -done - -printf ">> restic backup finished after "$SECONDS" seconds!\n" diff --git a/scripts/restic/n100.sh b/scripts/restic/n100.sh deleted file mode 100755 index d59ec3e..0000000 --- a/scripts/restic/n100.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash - -# author: Daniel Sommer -# license: MIT - -[[ "$EUID" != 0 ]] && printf "error: permission denied!\n" >&2 && exit 1 - -directories=( - "/etc" - "/mnt/storage/audiobooks" - "/mnt/storage/comics" - "/mnt/storage/documents" - "/mnt/storage/ebooks" - "/mnt/storage/images" - "/mnt/storage/music" - "/mnt/storage/software" - "/mnt/storage/syncthing" - "/mnt/storage/videos" -) - -printf ">> starting restic backup...\n" - -for directory in ${directories[@]}; do - seconds="$SECONDS" - printf "\n> backing up '"$directory"'...\n" - restic backup --verbose --no-scan --retry-lock 3h "$directory" - printf "> backup of '"$directory"' finished after "$(( $SECONDS - $seconds ))" seconds!\n" -done - -printf ">> restic backup finished after "$SECONDS" seconds!\n" diff --git a/scripts/restic/restic.sh b/scripts/restic/restic.sh deleted file mode 100755 index 9c2e483..0000000 --- a/scripts/restic/restic.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash - -# author: Daniel Sommer -# license: MIT - -# exit on error - -# check permissions -[[ "$EUID" != 0 ]] && printf "error: permission denied!\n" >&2 && exit 1 - -# check if script exists -script="$(dirname $(realpath "$0"))/$(hostname).sh" -[[ ! -x "$script" ]] && printf "error: script '"$script"' does not exist or is not executable!\n" >&2 && exit 1 - -# get hostname -host="$(hostname)" -[[ -z "$host" ]] && host="$HOST" - -# setup restic -export RESTIC_REPOSITORY="rest:http://192.168.100.101:8000" -export RESTIC_PASSWORD="\$Velvet90" -export RESTIC_COMPRESSION="max" -export RESTIC_CACHE_DIR="/var/cache/restic" - -# setup log file -log="/var/log/restic-"$(hostname)".log" - -# source / execute restic script -source "$script" 2>&1 | tee "$log" - -# send a notification when finished -/home/velvettear/.dots/scripts/notify.sh "backups" "$log" --title "$host" --icon "green_circle" diff --git a/scripts/update.sh b/scripts/update.sh deleted file mode 100755 index 095433c..0000000 --- a/scripts/update.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env bash - -# author: Daniel Sommer -# license: MIT - -# debian update script - -# exit on ctrl-c -trap 'printf ""$font_colored_bold"\n>> stopping system update after "$SECONDS" seconds..."$font_default"\n" && exit 1' SIGINT - -# font styles & colors -font_default="\e[0m" -font_colored="\e[32;1m" -font_colored_bold="\e[31;1m" - -[[ "$EUID" != "0" ]] && printf ""$font_colored_bold">> error: permission denied!"$font_default"\n" && exit 1 - -for arg in "$@"; do - case "$arg" in - -n|--noconfirm) - noconfirm="true" - ;; - -r|--reboot) - reboot="true" - ;; - esac -done - -printf ""$font_colored_bold">> system update started..."$font_default"\n" - -printf ""$font_colored"> updating packages..."$font_default"\n" -/usr/bin/apt-get update -[[ "$noconfirm" ]] && /usr/bin/apt-get dist-upgrade -y || /usr/bin/apt-get dist-upgrade - -printf ""$font_colored"> cleaning cache..."$font_default"\n" -rm -rf "/var/cache//usr/bin/apt-get/*" -[[ "$noconfirm" ]] && /usr/bin/apt-get clean -y || /usr/bin/apt-get clean - -printf ""$font_colored"> removing orphaned packages..."$font_default"\n" -[[ "$noconfirm" ]] && /usr/bin/apt-get autoremove --purge -y || /usr/bin/apt-get autoremove --purge - -printf ""$font_colored"> removing \"no valid subscription\" message..."$font_default"\n" -sed -i.bak "s/data.status.* !== 'ACTIVE'/false/I" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js - -printf ""$font_colored"> updating restic..."$font_default"\n" -restic self-update - -#printf ""$font_colored"> installing dark theme..."$font_default"\n" -#bash <(curl -s https://raw.githubusercontent.com/Weilbyte/PVEDiscordDark/master/PVEDiscordDark.sh ) install - -printf ""$font_colored_bold">> system updated finished after "$SECONDS" seconds!"$font_default"\n" - -[[ ! "$reboot" ]] && exit 0 - -timeout="5" -printf ""$font_colored"> rebooting system in " -while [[ "$timeout" -gt "0" ]]; do - printf "$timeout... " - timeout="$(( timeout - 1 ))" - sleep 1 -done -printf "now!"$font_default"\n" -systemctl reboot diff --git a/scripts/zfs-scrub.sh b/scripts/zfs-scrub.sh deleted file mode 100755 index 94c7520..0000000 --- a/scripts/zfs-scrub.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -# author: Daniel Sommer -# license: MIT - -[[ "$EUID" != 0 ]] && printf "error: permission denied!\n" && exit 1 - -printf "scrubbing all available zfs pools...\n" - -mapfile -t pools < <(zpool list | tail -n +2 | awk '{print $1}') -for pool in "${pools[@]}"; do - timestamp="$SECONDS" - printf "scrubbing zfs pool '"$pool"'...\n" - zpool scrub -w "$pool" - printf "scrubbing zfs pool '"$pool"' finished after $(( $SECONDS - $timestamp )) seconds!\n" -done - -printf "scrubbing all available zfs pools finished after $SECONDS seconds!\n" diff --git a/systemd/prepare-fs.service b/systemd/prepare-fs.service deleted file mode 100644 index 0e67e1b..0000000 --- a/systemd/prepare-fs.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=filesystem preparation -Before=pveproxy.service -Before=nginx.service - -[Service] -Type=oneshot -ExecStart=/etc/velvettear/scripts/prepare-fs.sh - -[Install] -WantedBy=multi-user.target diff --git a/systemd/restic/restic.service b/systemd/restic/restic.service deleted file mode 100644 index 8bdb84c..0000000 --- a/systemd/restic/restic.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=restic backup - -[Service] -Type=oneshot -ExecStart=/home/velvettear/.dots/scripts/restic/restic.sh -ExecStartPost=/home/velvettear/.dots/scripts/notify.sh "backups" "/var/log/restic-%i.log" --title "%i" --icon "green_circle" - -[Install] -WantedBy=multi-user.target diff --git a/systemd/restic/restic.timer b/systemd/restic/restic.timer deleted file mode 100644 index eba639e..0000000 --- a/systemd/restic/restic.timer +++ /dev/null @@ -1,8 +0,0 @@ -[Unit] -Description=restic backup - -[Timer] -OnCalendar=*-*-* 00:03:00 - -[Install] -WantedBy=timers.target diff --git a/systemd/zfs/zfs-scrub.service b/systemd/zfs/zfs-scrub.service deleted file mode 100644 index 8c41ac6..0000000 --- a/systemd/zfs/zfs-scrub.service +++ /dev/null @@ -1,9 +0,0 @@ -[Unit] -Description=scrub all available zfs pools - -[Service] -Type=simple -ExecStart=/etc/velvettear/scripts/zfs-scrub.sh - -[Install] -WantedBy=multi-user.target diff --git a/systemd/zfs/zfs-scrub.timer b/systemd/zfs/zfs-scrub.timer deleted file mode 100644 index e3cb11c..0000000 --- a/systemd/zfs/zfs-scrub.timer +++ /dev/null @@ -1,8 +0,0 @@ -[Unit] -Description=scrub all available zfs pools weekly - -[Timer] -OnCalendar=Sun *-*-* 08:00:00 - -[Install] -WantedBy=timers.target diff --git a/zsh/zprofile b/zsh/zprofile deleted file mode 100755 index a00476f..0000000 --- a/zsh/zprofile +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env zsh - -# author: Daniel Sommer -# license: MIT - -# export environment variables - -# set .dots directory -export VELVETTEAR_DOTS="$HOME/.dots" - -# set prompt -export PROMPT="%(!.%F{red}.)%n@%m > %/%(!.#.$) %f" - -# set general variables -export USER="$(whoami)" -export HOST="$(hostname)" -export HOSTNAME="$HOST" -export TMP="/tmp" -export TEMP="/tmp" -export TMPDIR="/tmp" - -# set nvim as default editor -export EDITOR="nvim" -export VISUAL="nvim" -export PAGER="less" - -# configure the shell history -export HISTFILE="$HOME/.zhistory" -export SAVEHIST="100" -export HISTSIZE="10000" -export HISTTIMEFORMAT="%d.%m.%Y %H:%M:%S" -export HISTCONTROL="ignoredups" - -# set all kinds of aliases - -# file and directory listings -alias ls="ls --color=auto" -alias la="ls -a --color=auto" -alias ll="ls -l --color=auto" -alias lla="ls -la --color=auto" - -# grep -alias grep="grep --color=auto" -alias fgrep="fgrep --color=auto" -alias egrep="egrep --color=auto" - -# diff -alias diff="diff --color=auto" - -# tar -alias tarp="tar -I pigz -cf -v" -alias untarp="tar -I pigz -xf" - -# general -alias ..="cd .." -alias whereami="realpath ." -alias c="clear" - -# create / delete / copy / move -alias rmr="rm -r" -alias rmrf="rm -rf" -alias cpr="cp -R" -alias cprf="cp -Rf" -alias mkdirp="mkdir -p" - -# applications -alias vi="nvim" -alias vim="nvim" - -# scripts -alias update="sudo $VELVETTEAR_DOTS/scripts/update.sh" diff --git a/zsh/zshrc b/zsh/zshrc deleted file mode 100755 index dceccae..0000000 --- a/zsh/zshrc +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env zsh - -# author: Daniel Sommer -# license: MIT - -# exit if user is not root -[[ "$EUID" != "0" ]] && return -echo "LOGIN AS ROOT"