minor fixes
authorAJ ONeal <aj@therootcompany.com>
Mon, 6 Jul 2020 04:15:25 +0000 (04:15 +0000)
committerAJ ONeal <aj@therootcompany.com>
Mon, 6 Jul 2020 04:15:33 +0000 (04:15 +0000)
vps-addswap/install.sh
vps-utils/install.sh

index f1f559f859ba2e40b96c4062fb363406f62256ff..e3e3702d254d2621cfe8e96b45373f76831c6867 100644 (file)
@@ -7,6 +7,16 @@
     default_size=2G
     my_size=${1:-$default_size}
 
+    if [ "0" != "$EUID" ] && [ "0" != "$UID" ]; then
+      echo Usage:
+      echo '        sudo env PATH="$PATH" vps-addswap' $my_size
+      exit 1
+    fi
+
+    if [ -f "/var/swapfile" ]; then
+      swapoff /var/swapfile
+    fi
+
     # Allocate a swapfile
     fallocate -l "$my_size" /var/swapfile
 
@@ -20,5 +30,4 @@
 
     # Cause swap to be activated on boot
     echo '/var/swapfile none swap sw 0 0' | tee -a /etc/fstab
-
 }
index 029807bd6ac4a92365d7e5cacdd3c1b81725aaa6..1f664e941d580e6565bb14fbc745079abd4d76d2 100644 (file)
@@ -1,10 +1,14 @@
+#!/bin/bash
+
 {
-    rm -f "$HOME/.local/bin/vps-myip" "$HOME/.local/bin/vps-addswap" "$HOME/.local/bin/cap-net-bind"
-    #webi_download "$WEBI_HOST/packages/vps-utils/" "$HOME/.local/bin/"
+    set -e
+    set -u
+
+    rm -f "$HOME/.local/bin/myip" "$HOME/.local/bin/vps-myip" "$HOME/.local/bin/vps-addswap" "$HOME/.local/bin/cap-net-bind"
     webi_download "$WEBI_HOST/packages/vps-utils/cap-net-bind.sh" "$HOME/.local/bin/cap-net-bind"
-    webi_download "$WEBI_HOST/packages/vps-utils/vps-myip.sh" "$HOME/.local/bin/vps-myip"
-    webi_download "$WEBI_HOST/packages/vps-utils/myip.sh" "$HOME/.local/bin/myip"
     webi_download "$WEBI_HOST/packages/vps-utils/vps-addswap.sh" "$HOME/.local/bin/vps-addswap"
+    webi_download "$WEBI_HOST/packages/myip/myip.sh" "$HOME/.local/bin/myip"
+    ln -s "$HOME/.local/bin/myip" "$HOME/.local/bin/vps-myip"
     chmod a+x "$HOME/.local/bin/cap-net-bind"
     chmod a+x "$HOME/.local/bin/myip"
     chmod a+x "$HOME/.local/bin/vps-"*