fix: stuff

This commit is contained in:
Strix 2024-06-04 14:43:05 +02:00
parent dd70dd0ad4
commit ba52a96a60
8 changed files with 39 additions and 121 deletions

View file

@ -1 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCeNQfnbyyF3sht43vH5BcXDPca8nWu6bKPVGvAlWBOq4Av8ME2IQgwVe9nJ05r73ZY02/Vdqc01a8wyK5Hmw0XlPL0Cn6wc9QoiscOvq5lMUK87S2tr3EVLGkgl8o7nmVuWgLewyojiORjM02P1PZEiFhKPXVEQFxU0dFz9QtpAdm0u78Xn2HTukHpXSv44R3XDDMFZ3Ek/XRuS6J9dZVxGkgCLQhK8kpfbxuiYxaRC7MHgGlYuxjLuZ6P4i+V+SSSShfCGdm6U9bgeIAwftN6a8Pc9+OsBeZGSUrGjZjRlD35q0a7fbpoS8pKTfbwgf/ijYeu3JmAQUlY+H959mIpg4H9XOgRrKVJSYwx5/BGuhmWgVy6HIYpXCQfEbLE7QDmwC2C430KzAH6jCcrRNyurIUCuO4iq9dwoQTzboMccOK79S2Z+1B5fYgS3BZgaiTUBSME2G2FriM6utgleiBnvFu/p7oH2I8ZHL/aVcSWAw0gbzsr7ADywAuiDNZk18c= raine@ryuk ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCeNQfnbyyF3sht43vH5BcXDPca8nWu6bKPVGvAlWBOq4Av8ME2IQgwVe9nJ05r73ZY02/Vdqc01a8wyK5Hmw0XlPL0Cn6wc9QoiscOvq5lMUK87S2tr3EVLGkgl8o7nmVuWgLewyojiORjM02P1PZEiFhKPXVEQFxU0dFz9QtpAdm0u78Xn2HTukHpXSv44R3XDDMFZ3Ek/XRuS6J9dZVxGkgCLQhK8kpfbxuiYxaRC7MHgGlYuxjLuZ6P4i+V+SSSShfCGdm6U9bgeIAwftN6a8Pc9+OsBeZGSUrGjZjRlD35q0a7fbpoS8pKTfbwgf/ijYeu3JmAQUlY+H959mIpg4H9XOgRrKVJSYwx5/BGuhmWgVy6HIYpXCQfEbLE7QDmwC2C430KzAH6jCcrRNyurIUCuO4iq9dwoQTzboMccOK79S2Z+1B5fYgS3BZgaiTUBSME2G2FriM6utgleiBnvFu/p7oH2I8ZHL/aVcSWAw0gbzsr7ADywAuiDNZk18c= strix@ryuk

View file

@ -4,6 +4,6 @@ describe="Setup git"
scripts="@distro @self" scripts="@distro @self"
apply() { apply() {
git config --global user.name Raine git config --global user.name Strix
git config --global user.email raine@ixvd.net git config --global user.email strix@saluco.nl
} }

View file

@ -1,8 +0,0 @@
#!/bin/sh
apply() {
echo "------------ WARNING ------------"
echo "BACKUPS ARE NOT SETUP ON DEBIAN! "
echo " PLEASE SETUP MANUALLY "
echo "---------------------------------"
}

View file

@ -1,4 +0,0 @@
#!/bin/sh
describe="Setup restic backups"
scripts="@distro" # only distro

View file

@ -1,41 +0,0 @@
#!/bin/bash
HOSTNAME=${HOSTNAME:-$(hostname)}
log() {
echo "log: $@"
if [ -f "/var/backups/ntfy.env" ]; then
. /var/backups/ntfy.env
curl \
-s \
-d "$@" \
${NTFY_URL:-https://push.ixvd.net/logs}
fi
}
log starting backup for $HOSTNAME
restic \
-r /var/backups/$HOSTNAME \
-p /var/backups/$HOSTNAME.secret \
backup \
--tag auto \
--exclude-caches \
--exclude dist \
--exclude target \
--exclude node_modules \
--exclude bin \
--exclude .cache \
--exclude '.config/*/cache' \
--exclude '.config/*/Cache' \
--exclude .cargo/git \
--exclude .cargo/registry \
--exclude '.rustup' \
--exclude '.local' \
--exclude '.var' \
--exclude Steam \
--exclude '.config/Code' \
--exclude '.config/Code - OSS' \
--exclude 'code/linux' \
--exclude Downloads \
/srv /home /etc
log backup finished with $?

View file

@ -1,10 +0,0 @@
#!/bin/sh
HOSTNAME=${HOSTNAME:-$(hostname)}
[ -d "/var/backups" ] || mkdir -p /var/backups
[ -f "/var/backups/$HOSTNAME.secret" ] || openssl rand -hex 64 > /var/backups/$HOSTNAME.secret
restic init \
-r /var/backups/$HOSTNAME \
-p /var/backups/$HOSTNAME.secret

View file

@ -1,11 +0,0 @@
#!/bin/bash
# sync backup to *the* external
HOSTNAME=${HOSTNAME:-$(hostname)}
set -e
rsync \
--info=progress2 \
-avzylu \

80
dot
View file

@ -3,7 +3,7 @@
ask=0 ask=0
is_function() { is_function() {
type "$1" 2> /dev/null | sed "s/$1//" | grep -qwi function type "$1" 2>/dev/null | sed "s/$1//" | grep -qwi function
} }
curr_distro() { curr_distro() {
@ -23,22 +23,7 @@ func() {
[ "$(id -u)" = "0" ] && sh -c "$ecmd" || sudo sh -c "$ecmd" [ "$(id -u)" = "0" ] && sh -c "$ecmd" || sudo sh -c "$ecmd"
unset ecmd unset ecmd
fi fi
is_function $2 && $2 is_function $2 && $2
}
get_command() {
case $1 in
a*)
printf "apply"
;;
u*)
printf "undo"
;;
*)
echo "err: not supported" >&2
exit 1
;;
esac
} }
# only run this *in crate dir* # only run this *in crate dir*
@ -51,25 +36,25 @@ run_crate() {
if [ $enabled -ne 1 ]; then if [ $enabled -ne 1 ]; then
return return
fi fi
cmd=$(get_command $1) cmd=$1
scripts=${scripts:-"@self @distro"} scripts=${scripts:-"@self @distro"}
for s in $scripts; do for s in $scripts; do
echo "exec($(basename $PWD)): $s/$cmd" echo "exec($(basename $PWD)): $s/$cmd"
case $s in case $s in
@self) @self)
func ./crate.sh $cmd func ./crate.sh $cmd
;; ;;
@distro) @distro)
unset -f super_$cmd unset -f super_$cmd
unset -f $cmd unset -f $cmd
include ./crate.$(curr_distro).sh include ./crate.$(curr_distro).sh
func ./crate.$(curr_distro).sh $cmd func ./crate.$(curr_distro).sh $cmd
unset -f super_$cmd unset -f super_$cmd
unset -f $cmd unset -f $cmd
include ./crate.sh include ./crate.sh
;; ;;
*) *)
sh $s sh $s
;; ;;
esac esac
done done
@ -80,18 +65,25 @@ echo "# user: $USER (${UID:-$(id -u)})"
echo "# groups: $(groups)" echo "# groups: $(groups)"
echo "# distro: $(curr_distro)" echo "# distro: $(curr_distro)"
if [ $# -eq 2 ]; then cmd=$1
[ -d crates/*$1 ] || exit 1 if [ -z "$cmd" ]; then
cd crates/*$1 echo "usage: $0 <command> [...args]"
run_crate $2 exit 1
cd ../.. else
else shift
[ $# -eq 0 ] && exit 2
for crate in $(find ./crates -mindepth 1 -maxdepth 1 -type d | sort); do
cd $crate
run_crate $1
cd ../..
done
fi fi
for c in ${@:-$(ls crates)}; do
[ -d crates/*$c ] || exit 1
cd crates/*$c
case $cmd in
a | apply)
run_crate apply
;;
u | undo)
run_crate undo
;;
*) exit 1 ;;
esac
cd ../..
done