diff --git a/installer/prereq.sh b/installer/prereq.sh index 34f309b..9c0606b 100755 --- a/installer/prereq.sh +++ b/installer/prereq.sh @@ -63,6 +63,12 @@ if [[ -z "$(lsmod | grep br_netfilter)" ]]; then echo "br_netfilter" >/etc/modules-load.d/br_netfilter.conf fi +# Install ufw +if ! command -v ufw &>/dev/null; then + stage "Installing ufw" + apt-get install -y ufw +fi + # ------------------------------- # fstab changes # We do not edit original file, instead we create a temp file with original and edit it. diff --git a/installer/sashimono-uninstall.sh b/installer/sashimono-uninstall.sh index 4aa238a..9f49a10 100755 --- a/installer/sashimono-uninstall.sh +++ b/installer/sashimono-uninstall.sh @@ -17,8 +17,8 @@ function confirm() { read -p "'y' or 'n' expected: " yn /dev/null | head -n 1) + instancename=$(echo $cfgpath | rev | cut -d '/' -f 3 | rev) + peerport=$(jq .mesh.port $cfgpath) + userport=$(jq .user.port $cfgpath) + output=$($SASHIMONO_BIN/user-uninstall.sh $user $peerport $userport $instancename | tee /dev/stderr) [ "${output: -10}" != "UNINST_SUC" ] && echo "Uninstall user '$user' failed. Aborting." && exit 1 done fi + + # Find if there are any garbage rules that are created by sashimono and remove them. + prefix="sashi" + ufw status | grep -E ^[0-9]+,[0-9]+/tcp\\s+ALLOW\\s+Anywhere\\s+\#\\s$prefix-.+$ | while read -r line; do + ports=$(echo $line | cut -d ' ' -f 1) + echo "Removing found garbage ufw $ports rule..." + p1=$(echo $ports | cut -d ',' -f 1) + p2=$(echo $ports | cut -d ',' -f 2 | cut -d '/' -f 1) + ufw delete allow "$p1","$p2"/tcp + done fi echo "Removing Sashimono cgroup creation service..." @@ -157,9 +172,9 @@ if grep -q "^$MB_XRPL_USER:" /etc/passwd; then fi echo "Deleting message board user..." - # Killall command is not found in every linux systems, therefore pkill command is used. + # Killall command is not found in every linux systems, therefore pkill command is used. # A small timeout(0.5 second) is applied before deleting the user because it takes some time to kill all the processes - loginctl disable-linger $MB_XRPL_USER + loginctl disable-linger $MB_XRPL_USER pkill -u $MB_XRPL_USER # Kill any running processes. sleep 0.5 userdel -f "$MB_XRPL_USER"