From 1d31567e9c8d050488703b01ab03217d9889a95f Mon Sep 17 00:00:00 2001 From: pvincent Date: Thu, 22 Jun 2023 12:28:09 +0400 Subject: [PATCH] root required for init.sh --- init.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/init.sh b/init.sh index 198b021..d87455c 100755 --- a/init.sh +++ b/init.sh @@ -2,22 +2,24 @@ set -Eeuo pipefail -CURDIR=$PWD +[ "$(id -u)" -ne 0 ] && echo 'root privilege required' && exit 1 + +readonly DEBIAN_BASH_DIR='/opt/debian-bash' #remove /etc/skel/.bashrc if [ -e /etc/skel/.bashrc ]; then rm /etc/skel/.bashrc fi -ORIGINAL="ORIGINAL" +readonly ORIGINAL="ORIGINAL" declare -a arr=(/etc/bash.bashrc /etc/inputrc /etc/vim/vimrc) for i in "${arr[@]}"; do if [ ! -f "$i.$ORIGINAL" ]; then - - echo "$i needs installation $(basename \\"$i\\")" mv "$i" "$i.$ORIGINAL" - ln -s "$CURDIR/$(basename \\"$i\\")" "$i" + basefile=$(basename "$i") + ln -s "$DEBIAN_BASH_DIR/$basefile" "$i" + echo "<$i> installed successfully!" else echo "<$i> already overriden!" fi