Housekeeping
- Update README - Run shellcheck on .sh files - Add helper scripts - Remove eirene vm variant - Add post-install checklist Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
echo "Starting impermanence mount with source: $source, target: $target, path: $path."
|
||||
echo "Starting impermanence mount with source: ${source}, target: ${target}, path: ${path}."
|
||||
|
||||
source_current="$source"
|
||||
target_current="$target"
|
||||
source_current="${source}"
|
||||
target_current="${target}"
|
||||
|
||||
IFS='/' read -ra path_parts <<< "$path"
|
||||
IFS='/' read -ra path_parts <<< "${path}"
|
||||
unset "path_parts[-1]"
|
||||
|
||||
for part in "${path_parts[@]}"; do
|
||||
source_current="$source_current/$part"
|
||||
target_current="$target_current/$part"
|
||||
source_current="${source_current}/${part}"
|
||||
target_current="${target_current}/${part}"
|
||||
|
||||
if [ ! -d "$source_current" ]; then
|
||||
if [[ ! -d "${source_current}" ]]; then
|
||||
break
|
||||
fi
|
||||
|
||||
read -r mode owner group <<< "$(stat -c '%a %u %g' "$source_current")"
|
||||
install -d -m "$mode" -o "$owner" -g "$group" "$target_current"
|
||||
read -r mode owner group <<< "$(stat -c '%a %u %g' "${source_current}")"
|
||||
install -d -m "${mode}" -o "${owner}" -g "${group}" "${target_current}"
|
||||
done
|
||||
|
@@ -1,38 +1,38 @@
|
||||
echo "Stopping impermanence mount with source: $source, target: $target, path: $path."
|
||||
echo "Stopping impermanence mount with source: ${source}, target: ${target}, path: ${path}."
|
||||
|
||||
source_current="$source"
|
||||
target_current="$target"
|
||||
source_current="${source}"
|
||||
target_current="${target}"
|
||||
|
||||
IFS='/' read -ra path_parts <<< "$path"
|
||||
IFS='/' read -ra path_parts <<< "${path}"
|
||||
unset "path_parts[-1]"
|
||||
|
||||
for part in "${path_parts[@]}"; do
|
||||
source_current="$source_current/$part"
|
||||
target_current="$target_current/$part"
|
||||
source_current="${source_current}/${part}"
|
||||
target_current="${target_current}/${part}"
|
||||
|
||||
if [ ! -d "$target_current" ]; then
|
||||
if [[ ! -d "${target_current}" ]]; then
|
||||
break
|
||||
fi
|
||||
|
||||
if [ -d "$source_current" ]; then
|
||||
if [[ -d "${source_current}" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
read -r mode owner group <<< "$(stat -c '%a %u %g' "$target_current")"
|
||||
install -d -m "$mode" -o "$owner" -g "$group" "$source_current"
|
||||
read -r mode owner group <<< "$(stat -c '%a %u %g' "${target_current}")"
|
||||
install -d -m "${mode}" -o "${owner}" -g "${group}" "${source_current}"
|
||||
done
|
||||
|
||||
source=$(realpath -m "$source/$path")
|
||||
target=$(realpath -m "$target/$path")
|
||||
source=$(realpath -m "${source}/${path}")
|
||||
target=$(realpath -m "${target}/${path}")
|
||||
|
||||
if [ ! -e "$target" ] || { [ -d "$target" ] && [ -z "$(ls -A "$target")" ]; } || { [ -f "$target" ] && [ ! -s "$target" ]; }; then
|
||||
if [[ ! -e "${target}" ]] || { [[ -d "${target}" ]] && [[ -z "$(ls -A "${target}")" ]]; } || { [[ -f "${target}" ]] && [[ ! -s "${target}" ]]; }; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -e "$source" ]; then
|
||||
>&2 echo "Error: Source $source already exists. Cannot move $target to $source."
|
||||
if [[ -e "${source}" ]]; then
|
||||
>&2 echo "Error: Source ${source} already exists. Cannot move ${target} to ${source}."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Moving target $target to source $source."
|
||||
mv "$target" "$source"
|
||||
echo "Moving target ${target} to source ${source}."
|
||||
mv "${target}" "${source}"
|
||||
|
@@ -1,7 +1,7 @@
|
||||
delete_subvolume_recursively() {
|
||||
IFS=$'\n'
|
||||
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
|
||||
delete_subvolume_recursively "/mnt/btrfs/$i"
|
||||
delete_subvolume_recursively "/mnt/btrfs/${i}"
|
||||
done
|
||||
btrfs subvolume delete "$1"
|
||||
}
|
||||
@@ -12,11 +12,11 @@ mount /dev/mapper/luks /mnt/btrfs
|
||||
if [[ -e /mnt/btrfs/@ ]]; then
|
||||
mkdir -p /mnt/btrfs/@.bak
|
||||
timestamp=$(date --date="@$(stat -c %Y /mnt/btrfs/@)" "+%Y-%m-%d_%H:%M:%S")
|
||||
mv /mnt/btrfs/@ "/mnt/btrfs/@.bak/$timestamp"
|
||||
mv /mnt/btrfs/@ "/mnt/btrfs/@.bak/${timestamp}"
|
||||
fi
|
||||
|
||||
find /mnt/btrfs/@.bak/ -maxdepth 1 -mtime +14 | while IFS= read -r i; do
|
||||
delete_subvolume_recursively "$i"
|
||||
delete_subvolume_recursively "${i}"
|
||||
done
|
||||
|
||||
btrfs subvolume create /mnt/btrfs/@
|
||||
|
@@ -1,7 +1,7 @@
|
||||
case "$2" in
|
||||
connectivity-change)
|
||||
if timezone=$(curl --fail https://ipapi.co/timezone); then
|
||||
timedatectl set-timezone "$timezone"
|
||||
timedatectl set-timezone "${timezone}"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
@@ -1,4 +1,4 @@
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
if [[ "$(id -u)" -ne 0 ]]; then
|
||||
echo "This script must be run as root or with sudo privileges."
|
||||
exit 1
|
||||
fi
|
||||
@@ -6,12 +6,12 @@ fi
|
||||
delete_subvolume_recursively() {
|
||||
IFS=$'\n'
|
||||
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
|
||||
delete_subvolume_recursively "/mnt/btrfs/$i"
|
||||
delete_subvolume_recursively "/mnt/btrfs/${i}"
|
||||
done
|
||||
btrfs subvolume delete "$1"
|
||||
}
|
||||
|
||||
if [[ -e /mnt/btrfs && $(mountpoint -q /mnt/btrfs) ]]; then
|
||||
if [[ -e /mnt/btrfs && -n $(mountpoint -q /mnt/btrfs) ]]; then
|
||||
echo "/mnt/btrfs is already mounted. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
@@ -20,9 +20,9 @@ mkdir -p /mnt/btrfs
|
||||
mount /dev/mapper/luks /mnt/btrfs
|
||||
|
||||
if [[ -e /mnt/btrfs/@.bak ]]; then
|
||||
if [ "$(ls -A /mnt/btrfs/@.bak)" ]; then
|
||||
if [[ -n "$(ls -A /mnt/btrfs/@.bak)" ]]; then
|
||||
for i in /mnt/btrfs/@.bak/*; do
|
||||
delete_subvolume_recursively "$i"
|
||||
delete_subvolume_recursively "${i}"
|
||||
done
|
||||
else
|
||||
echo "/mnt/btrfs/@.bak is empty. Nothing to delete."
|
||||
|
@@ -1,21 +1,21 @@
|
||||
for dir in "$HOME"/.config/sops-nix/secrets/gpg-agent/*; do
|
||||
keyfile="$dir/key"
|
||||
passfile="$dir/pass"
|
||||
for dir in "${HOME}"/.config/sops-nix/secrets/gpg-agent/*; do
|
||||
keyfile="${dir}/key"
|
||||
passfile="${dir}/pass"
|
||||
|
||||
if [ ! -f "$keyfile" ]; then
|
||||
if [[ ! -f "${keyfile}" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ -f "$passfile" ]; then
|
||||
gpg2 --batch --yes --pinentry-mode loopback --passphrase-file "$passfile" --import "$keyfile"
|
||||
if [[ -f "${passfile}" ]]; then
|
||||
gpg2 --batch --yes --pinentry-mode loopback --passphrase-file "${passfile}" --import "${keyfile}"
|
||||
else
|
||||
gpg2 --batch --yes --import "$keyfile"
|
||||
gpg2 --batch --yes --import "${keyfile}"
|
||||
fi
|
||||
|
||||
gpg2 --with-colons --import-options show-only --import "$keyfile" | grep '^fpr' | cut -d: -f10 | while read -r KEY_ID; do
|
||||
echo "$KEY_ID:6:" >> "$GNUPGHOME"/otrust.txt
|
||||
gpg2 --with-colons --import-options show-only --import "${keyfile}" | grep '^fpr' | cut -d: -f10 | while read -r KEY_ID; do
|
||||
echo "${KEY_ID}:6:" >> "${GNUPGHOME}"/otrust.txt
|
||||
done
|
||||
done
|
||||
|
||||
gpg2 --import-ownertrust "$GNUPGHOME"/otrust.txt
|
||||
rm "$GNUPGHOME"/otrust.txt
|
||||
gpg2 --import-ownertrust "${GNUPGHOME}"/otrust.txt
|
||||
rm "${GNUPGHOME}"/otrust.txt
|
||||
|
@@ -7,7 +7,7 @@ handle() {
|
||||
cliphist decode <<< "$1" | wl-copy
|
||||
}
|
||||
|
||||
case $ROFI_RETV in
|
||||
case ${ROFI_RETV} in
|
||||
0) list ;;
|
||||
1) handle "$@" ;;
|
||||
esac
|
||||
|
@@ -7,7 +7,7 @@ handle() {
|
||||
cliphist delete <<< "$1"
|
||||
}
|
||||
|
||||
case $ROFI_RETV in
|
||||
case ${ROFI_RETV} in
|
||||
0) list ;;
|
||||
1) handle "$@" && list ;;
|
||||
esac
|
||||
|
@@ -1,19 +1,19 @@
|
||||
SOURCE_FILE=$(realpath -m "$1")
|
||||
TARGET_FILE=$(realpath -m "$2")
|
||||
|
||||
mkdir -p "$(dirname "$TARGET_FILE")"
|
||||
mkdir -p "$(dirname "${TARGET_FILE}")"
|
||||
|
||||
TEMP_FILE=$(mktemp)
|
||||
cat "$SOURCE_FILE" > "$TEMP_FILE"
|
||||
cat "${SOURCE_FILE}" > "${TEMP_FILE}"
|
||||
|
||||
if [ -f "$TARGET_FILE" ]; then
|
||||
if [[ -f "${TARGET_FILE}" ]]; then
|
||||
while IFS='=' read -r key value; do
|
||||
if ! grep -q "^${key}=" "$TEMP_FILE"; then
|
||||
echo "${key}=${value}" >> "$TEMP_FILE"
|
||||
if ! grep -q "^${key}=" "${TEMP_FILE}"; then
|
||||
echo "${key}=${value}" >> "${TEMP_FILE}"
|
||||
fi
|
||||
done < "$TARGET_FILE"
|
||||
done < "${TARGET_FILE}"
|
||||
fi
|
||||
|
||||
mv "$TEMP_FILE" "$TARGET_FILE"
|
||||
mv "${TEMP_FILE}" "${TARGET_FILE}"
|
||||
|
||||
echo "Configuration file $TARGET_FILE has been updated."
|
||||
echo "Configuration file ${TARGET_FILE} has been updated."
|
||||
|
@@ -1,11 +1,11 @@
|
||||
[ ! -L "$CONFIG"/wallpaper ] && ln -sf "$DEFAULT_WALLPAPER" "$CONFIG"/wallpaper
|
||||
[ ! -f "$CONFIG"/mode ] && echo "$DEFAULT_MODE" > "$CONFIG"/mode
|
||||
[[ ! -L "${CONFIG}"/wallpaper ]] && ln -sf "${DEFAULT_WALLPAPER}" "${CONFIG}"/wallpaper
|
||||
[[ ! -f "${CONFIG}"/mode ]] && echo "${DEFAULT_MODE}" > "${CONFIG}"/mode
|
||||
|
||||
WALLPAPER=""
|
||||
MODE=""
|
||||
|
||||
set_wallpaper() {
|
||||
if [ -f "$1" ]; then
|
||||
if [[ -f "$1" ]]; then
|
||||
WALLPAPER="$1"
|
||||
else
|
||||
echo "Invalid wallpaper path: $1"
|
||||
@@ -14,7 +14,7 @@ set_wallpaper() {
|
||||
}
|
||||
|
||||
set_mode() {
|
||||
if [ "$1" = "light" ] || [ "$1" = "dark" ]; then
|
||||
if [[ "$1" = "light" ]] || [[ "$1" = "dark" ]]; then
|
||||
MODE="$1"
|
||||
else
|
||||
echo "Invalid mode: $1. Use 'light' or 'dark'."
|
||||
@@ -23,7 +23,7 @@ set_mode() {
|
||||
}
|
||||
|
||||
toggle_mode() {
|
||||
if [ "$(cat "$CONFIG"/mode)" = "light" ]; then
|
||||
if [[ "$(cat "${CONFIG}"/mode)" = "light" ]]; then
|
||||
MODE="dark"
|
||||
else
|
||||
MODE="light"
|
||||
@@ -35,18 +35,18 @@ show_usage() {
|
||||
}
|
||||
|
||||
finish() {
|
||||
[ -n "$WALLPAPER" ] && ln -sf "$WALLPAPER" "$CONFIG"/wallpaper
|
||||
[ -n "$MODE" ] && echo "$MODE" > "$CONFIG"/mode
|
||||
[[ -n "${WALLPAPER}" ]] && ln -sf "${WALLPAPER}" "${CONFIG}"/wallpaper
|
||||
[[ -n "${MODE}" ]] && echo "${MODE}" > "${CONFIG}"/mode
|
||||
|
||||
"$ACTIVATION" > /dev/null
|
||||
"${ACTIVATION}" > /dev/null
|
||||
}
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
if [[ $# -eq 0 ]]; then
|
||||
finish
|
||||
else
|
||||
case "$1" in
|
||||
toggle)
|
||||
if [ $# -eq 1 ]; then
|
||||
if [[ $# -eq 1 ]]; then
|
||||
toggle_mode
|
||||
else
|
||||
show_usage
|
||||
@@ -54,7 +54,7 @@ else
|
||||
fi
|
||||
;;
|
||||
light)
|
||||
if [ $# -eq 1 ]; then
|
||||
if [[ $# -eq 1 ]]; then
|
||||
set_mode "light"
|
||||
else
|
||||
show_usage
|
||||
@@ -62,7 +62,7 @@ else
|
||||
fi
|
||||
;;
|
||||
dark)
|
||||
if [ $# -eq 1 ]; then
|
||||
if [[ $# -eq 1 ]]; then
|
||||
set_mode "dark"
|
||||
else
|
||||
show_usage
|
||||
@@ -70,7 +70,7 @@ else
|
||||
fi
|
||||
;;
|
||||
mode)
|
||||
if [ $# -eq 2 ]; then
|
||||
if [[ $# -eq 2 ]]; then
|
||||
set_mode "$2"
|
||||
else
|
||||
show_usage
|
||||
@@ -78,9 +78,9 @@ else
|
||||
fi
|
||||
;;
|
||||
wallpaper)
|
||||
if [ $# -ge 2 ] && [ $# -le 3 ]; then
|
||||
if [[ $# -ge 2 ]] && [[ $# -le 3 ]]; then
|
||||
set_wallpaper "$2"
|
||||
[ $# -eq 3 ] && set_mode "$3"
|
||||
[[ $# -eq 3 ]] && set_mode "$3"
|
||||
else
|
||||
show_usage
|
||||
exit 1
|
||||
|
Reference in New Issue
Block a user