From a9a7904f52f4f7bc078211323d46825b3c93d6d3 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 1 Jul 2020 04:52:03 +0000 Subject: [PATCH] add VPS utils --- vps-utils/README.md | 47 +++++++++++++++++++++++++++++++++++++++ vps-utils/cap-net-bind.sh | 17 ++++++++++++++ vps-utils/install.sh | 9 ++++++++ vps-utils/vps-addswap.sh | 1 + vps-utils/vps-myip.sh | 1 + 5 files changed, 75 insertions(+) create mode 100644 vps-utils/README.md create mode 100644 vps-utils/cap-net-bind.sh create mode 100644 vps-utils/install.sh create mode 120000 vps-utils/vps-addswap.sh create mode 120000 vps-utils/vps-myip.sh diff --git a/vps-utils/README.md b/vps-utils/README.md new file mode 100644 index 0000000..3dbce19 --- /dev/null +++ b/vps-utils/README.md @@ -0,0 +1,47 @@ +--- +title: VPS Utils +homepage: https://webinstall.dev/vps-utils +tagline: | + VPS Utils make it easy to setup and manage a VPS +description: | + VPS Utils includes shortcut commands for some common tasks, including `cap-net-bind`, 'vps-addswap', and 'vps-myip' +--- + +**cap-net-bind**: + +`cap-net-bind` will give the specified program the ability to listen on +privileged ports, such as 80 (http) and 443 (https) without `root` privileges or +`sudo`. + +```bash +sudo cap-net-bind node +``` + +This is the same as running the full command: + +```bash +setcap 'cap_net_bind_service=+ep' $(readlink -f $(which node)) +``` + +**vps-myip**: + +Will output externally detected IPv4 and IPv6 addresses. See +. + +```bash +vps-myip +``` + +```txt +IPv4 (A) : 136.36.196.101 +IPv6 (AAAA): 2605:a601:a919:9800:f8be:f2c4:9ad7:9763 +``` + +**vps-addswap**: + +Adds and activates permanent swap in `/var/swapfile`. See +. + +```bash +vps-addswap +``` diff --git a/vps-utils/cap-net-bind.sh b/vps-utils/cap-net-bind.sh new file mode 100644 index 0000000..30f1fe5 --- /dev/null +++ b/vps-utils/cap-net-bind.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +{ + set -e + set -u + + my_bin="$1" + if [ -z "$(which $my_bin)"]; then + echo "'$my_bin' not found" + exit 1 + fi + my_sudo="" + if [ -n "$(command -v sudo)" ]; then + my_sudo=sudo + fi + $my_sudo setcap 'cap_net_bind_service=+ep' $(readlink -f $(which $my_bin)) +} diff --git a/vps-utils/install.sh b/vps-utils/install.sh new file mode 100644 index 0000000..b8c6658 --- /dev/null +++ b/vps-utils/install.sh @@ -0,0 +1,9 @@ +{ + 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/" + 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/vps-addswap.sh" "$HOME/.local/bin/vps-addswap" + chmod a+x "$HOME/.local/bin/cap-net-bind"* + chmod a+x "$HOME/.local/bin/vps-"* +} diff --git a/vps-utils/vps-addswap.sh b/vps-utils/vps-addswap.sh new file mode 120000 index 0000000..e35a636 --- /dev/null +++ b/vps-utils/vps-addswap.sh @@ -0,0 +1 @@ +../vps-addswap/install.sh \ No newline at end of file diff --git a/vps-utils/vps-myip.sh b/vps-utils/vps-myip.sh new file mode 120000 index 0000000..aaa6265 --- /dev/null +++ b/vps-utils/vps-myip.sh @@ -0,0 +1 @@ +../vps-myip/install.sh \ No newline at end of file -- 2.25.1