initial commit for dotfiles etc.

This commit is contained in:
2022-04-28 23:36:42 +02:00
commit a9c2fb5508
205 changed files with 10609 additions and 0 deletions

41
scripts/import_single_file.bash Executable file
View File

@ -0,0 +1,41 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
# this script is supposed to apply changes in /sync/{home,root}_external to /sync/{home,root}_external and thus to / resp. ~/
# FIXME!!! WIP
# FIXME!!! syncing root stuff not yet implemented
# FIXME!!! user name/ group name/ home dir hard coded for now...
externalDir=/sync/home_external/
internalDir=/sync/home_internal/
userHome=/home/fabian/
user=fabian
group=fabian
if [[ -z "$1" ]]; then
echo "Error. No file(s) for import given"
exit 1
fi
file="$(find $internalDir -name $1)"
# if a file is merely changed, copy its content into the existing target directory
if [[ -e "$file" ]]; then
echo "copying file content of $1 to $file"
cat $1 > $file
exit 0
fi
# if a new file/ dir is created, copy it into the $internalDir retaining the relative path
# after that, copy/ hard link it to the $userHome directory and assign the correct user/ group
# NOTE: one could solve that by having the same user + group on every system
relPath="$(realpath --relative-to=$externalDir $1)" # should also contain the leaf name
echo "new file/dir. relative path: $relPath"
if [[ -f "$1" ]]; then
install -Dv $1 "$internalDir$relPath"
else
mkdir -pv "$internalDir$relPath"
fi
cp -lrv "$internalDir$relPath" $userHome
chown -v "$user:$group" "$userHome$relPath"
exit 0

8
scripts/mount_edi.sh Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
source /sync/scripts/mount_general.sh
sshMount edi edi fabian FabisDokumente

8
scripts/mount_garrus.sh Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
source /sync/scripts/mount_general.sh
sshMount fabian garrus fabian FabisDokumente media Filme

13
scripts/mount_general.sh Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
sshMount () {
args=($@)
args=(${args[@]:2})
for ((i=0; i < ${#args[@]}; i=i + 2)); do
sshfs $1@$2:/citadel/${args[$i]}/ /home/fabian/${args[$i + 1]}/ -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=8
done
}

8
scripts/unmount_edi.sh Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
source /sync/scripts/unmount_general.sh
sshUnmount FabisDokumente

8
scripts/unmount_garrus.sh Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
source /sync/scripts/unmount_general.sh
sshUnmount FabisDokumente Filme

11
scripts/unmount_general.sh Executable file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
sshUnmount () {
args=($@)
for d in ${args[@]}; do
fusermount -u /home/fabian/$d
done
}