From 7817eef8378d539d159c127617561fa5e961bac1 Mon Sep 17 00:00:00 2001 From: Gabriel Trabanco Llano Date: Sun, 19 Dec 2021 17:49:56 +0100 Subject: [PATCH] Fix check first if command exists --- src/wireguard/setup_wireguard.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/wireguard/setup_wireguard.sh b/src/wireguard/setup_wireguard.sh index ffc0ff4..2b76e51 100644 --- a/src/wireguard/setup_wireguard.sh +++ b/src/wireguard/setup_wireguard.sh @@ -15,24 +15,24 @@ elif [ -d "/data" ]; then fi WIREGUARD="${DATA_DIR}/wireguard" -ln -sf $WIREGUARD/usr/bin/wg-quick /usr/bin -ln -sf $WIREGUARD/usr/bin/wg /usr/bin -ln -s $WIREGUARD/usr/bin/bash /bin -ln -sf $WIREGUARD/usr/bin/qrencode /usr/bin -ln -s $WIREGUARD/usr/bin/htop /usr/bin -ln -s $WIREGUARD/usr/sbin/iftop /usr/sbin -ln -s $WIREGUARD/sbin/resolvconf /sbin +ln -sf "${WIREGUARD}/usr/bin/wg-quick" /usr/bin +ln -sf "${WIREGUARD}/usr/bin/wg" /usr/bin +[ ! -x "/bin/bash" ] && ln -s "${WIREGUARD}/usr/bin/bash" /bin +ln -sf "${WIREGUARD}/usr/bin/qrencode" /usr/bin +[ ! -x "/usr/bin/htop" ] && ln -s "${WIREGUARD}/usr/bin/htop" /usr/bin +[ ! -x "/usr/sbin/iftop" ] && ln -s "${WIREGUARD}/usr/sbin/iftop" /usr/sbin +[ ! -x "/sbin/resolvconf" ] && ln -s "${WIREGUARD}/sbin/resolvconf" /sbin # create symlink to wireguard config folder if [ ! -d "/etc/wireguard" ] then - ln -sf $WIREGUARD/etc/wireguard /etc/wireguard + ln -sf "${WIREGUARD}/etc/wireguard" /etc/wireguard fi # create symlink to resolvconf config file if [ ! -f "/etc/resolvconf.conf" ] then - ln -s $WIREGUARD/etc/resolvconf.conf /etc/ + ln -s "${WIREGUARD}/etc/resolvconf.conf" /etc/ fi # required by wg-quick @@ -50,14 +50,14 @@ if [ $? -eq 1 ] then ver=`uname -r` echo "loading wireguard..." - if [ -e /lib/modules/$ver/extra/wireguard.ko ]; then + if [ -e "/lib/modules/${ver}/extra/wireguard.ko" ]; then modprobe wireguard - elif [ -e $WIREGUARD/modules/wireguard-$ver.ko ]; then - insmod $WIREGUARD/modules/wireguard-$ver.ko + elif [ -e "${WIREGUARD}/modules/wireguard-${ver}.ko" ]; then + insmod "${WIREGUARD}/modules/wireguard-${ver}.ko" # iptable_raw required for wg-quick's use of iptables-restore - insmod $WIREGUARD/modules/iptable_raw-$ver.ko - insmod $WIREGUARD/modules/ip6table_raw-$ver.ko + insmod "${WIREGUARD}/modules/iptable_raw-${ver}.ko" + insmod "${WIREGUARD}/modules/ip6table_raw-${ver}.ko" else - echo "Unsupported Kernel version $ver" + echo "Unsupported Kernel version ${ver}" fi fi