diff --git a/install.sh b/install.sh index 048ea1d..1bded22 100755 --- a/install.sh +++ b/install.sh @@ -1,19 +1,21 @@ #!/usr/bin/env bash +run_directory=$(dirname "$0") + if [ -f $run_directory/.disabled ]; then echo "Installation is disabled. Exiting..." exit 0 fi echo "Copying Systemd units to system directory..." -for f in $(dirname "$0")/mounts.conf.d/*.conf; do +for f in $run_directory/mounts.conf.d/*.conf; do if [ ! -e "$f" ]; then continue fi source $f mountfile=$(echo ${mount[target]} | sed -e "s:/:-:g") mountfile=${mountfile:1}.mount - sudo cp $(dirname "$0")/template.mount /etc/systemd/system/$mountfile + sudo cp $run_directory/template.mount /etc/systemd/system/$mountfile sudo sed -i -e "s/PH_MAPPER/${mount[mapper]}/g" /etc/systemd/system/$mountfile sudo sed -i -e "s:PH_TARGET:${mount[target]}:g" /etc/systemd/system/$mountfile if [ "${mount[friendly]}" != '' ]; then @@ -23,7 +25,7 @@ for f in $(dirname "$0")/mounts.conf.d/*.conf; do fi if [ ${mount[autolock]} -eq 1 ]; then sudo mkdir /etc/systemd/system/systemd-cryptsetup@${mount[mapper]}.service.d - sudo cp $(dirname "$0")/close-vault.conf.template \ + sudo cp $run_directory/close-vault.conf.template \ /etc/systemd/system/systemd-cryptsetup@${mount[mapper]}.service.d/close-vault.conf sudo sed -i -e "s/PH_MOUNTFILE/$mountfile/g" \ /etc/systemd/system/systemd-cryptsetup@${mount[mapper]}.service.d/close-vault.conf