mirror of
https://github.com/pivpn/pivpn.git
synced 2024-12-18 19:00:15 +00:00
fix(dev-infra): move function before use
move err function above where it is first called
This commit is contained in:
parent
5ee9425ad4
commit
0e78a1148c
8 changed files with 32 additions and 32 deletions
|
@ -6,6 +6,10 @@ screen_size="$(stty size 2> /dev/null || echo 24 80)"
|
||||||
rows="$(echo "${screen_size}" | awk '{print $1}')"
|
rows="$(echo "${screen_size}" | awk '{print $1}')"
|
||||||
columns="$(echo "${screen_size}" | awk '{print $2}')"
|
columns="$(echo "${screen_size}" | awk '{print $2}')"
|
||||||
|
|
||||||
|
err() {
|
||||||
|
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
|
||||||
|
}
|
||||||
|
|
||||||
# Divide by two so the dialogs take up half of the screen, which looks nice.
|
# Divide by two so the dialogs take up half of the screen, which looks nice.
|
||||||
r=$((rows / 2))
|
r=$((rows / 2))
|
||||||
c=$((columns / 2))
|
c=$((columns / 2))
|
||||||
|
@ -69,10 +73,6 @@ if [[ "${PLAT}" == 'Alpine' ]]; then
|
||||||
CHECK_PKG_INSTALLED='apk --no-cache info -e'
|
CHECK_PKG_INSTALLED='apk --no-cache info -e'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
err() {
|
|
||||||
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
checkbackupdir() {
|
checkbackupdir() {
|
||||||
# Disabling shellcheck error $install_home sourced from $setupVars
|
# Disabling shellcheck error $install_home sourced from $setupVars
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
CHECK_PKG_INSTALLED='dpkg-query -s'
|
CHECK_PKG_INSTALLED='dpkg-query -s'
|
||||||
|
|
||||||
|
err() {
|
||||||
|
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
|
||||||
|
}
|
||||||
|
|
||||||
if grep -qsEe "^NAME\=['\"]?Alpine[a-zA-Z ]*['\"]?$" /etc/os-release; then
|
if grep -qsEe "^NAME\=['\"]?Alpine[a-zA-Z ]*['\"]?$" /etc/os-release; then
|
||||||
CHECK_PKG_INSTALLED='apk --no-cache info -e'
|
CHECK_PKG_INSTALLED='apk --no-cache info -e'
|
||||||
fi
|
fi
|
||||||
|
@ -18,10 +22,6 @@ fi
|
||||||
|
|
||||||
scriptDir="/opt/pivpn"
|
scriptDir="/opt/pivpn"
|
||||||
|
|
||||||
err() {
|
|
||||||
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
uninstallServer() {
|
uninstallServer() {
|
||||||
${SUDO} "${scriptDir}/uninstall.sh"
|
${SUDO} "${scriptDir}/uninstall.sh"
|
||||||
exit "${?}"
|
exit "${?}"
|
||||||
|
|
|
@ -26,6 +26,10 @@ setupConfigDir="/etc/pivpn"
|
||||||
pivpnFilesDir="/usr/local/src/pivpn"
|
pivpnFilesDir="/usr/local/src/pivpn"
|
||||||
pivpnScriptDir="/opt/pivpn"
|
pivpnScriptDir="/opt/pivpn"
|
||||||
|
|
||||||
|
err() {
|
||||||
|
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
|
||||||
|
}
|
||||||
|
|
||||||
PLAT="$(grep -sEe '^NAME\=' /etc/os-release \
|
PLAT="$(grep -sEe '^NAME\=' /etc/os-release \
|
||||||
| sed -E -e "s/NAME\=[\'\"]?([^ ]*).*/\1/")"
|
| sed -E -e "s/NAME\=[\'\"]?([^ ]*).*/\1/")"
|
||||||
|
|
||||||
|
@ -85,10 +89,6 @@ fi
|
||||||
# shellcheck disable=SC1090
|
# shellcheck disable=SC1090
|
||||||
source "${setupVars}"
|
source "${setupVars}"
|
||||||
|
|
||||||
err() {
|
|
||||||
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
### FIXME: introduce global lib
|
### FIXME: introduce global lib
|
||||||
spinner() {
|
spinner() {
|
||||||
local pid="${1}"
|
local pid="${1}"
|
||||||
|
|
|
@ -3,15 +3,15 @@
|
||||||
|
|
||||||
CLIENTS_FILE="/etc/wireguard/configs/clients.txt"
|
CLIENTS_FILE="/etc/wireguard/configs/clients.txt"
|
||||||
|
|
||||||
|
err() {
|
||||||
|
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
|
||||||
|
}
|
||||||
|
|
||||||
if [[ ! -s "${CLIENTS_FILE}" ]]; then
|
if [[ ! -s "${CLIENTS_FILE}" ]]; then
|
||||||
err "::: There are no clients to list"
|
err "::: There are no clients to list"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
err() {
|
|
||||||
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
scriptusage() {
|
scriptusage() {
|
||||||
echo "::: List any connected clients to the server"
|
echo "::: List any connected clients to the server"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
setupVars="/etc/pivpn/wireguard/setupVars.conf"
|
setupVars="/etc/pivpn/wireguard/setupVars.conf"
|
||||||
|
|
||||||
|
err() {
|
||||||
|
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
|
||||||
|
}
|
||||||
|
|
||||||
if [[ ! -f "${setupVars}" ]]; then
|
if [[ ! -f "${setupVars}" ]]; then
|
||||||
err "::: Missing setup vars file!"
|
err "::: Missing setup vars file!"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -10,10 +14,6 @@ fi
|
||||||
# shellcheck disable=SC1090
|
# shellcheck disable=SC1090
|
||||||
source "${setupVars}"
|
source "${setupVars}"
|
||||||
|
|
||||||
err() {
|
|
||||||
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
helpFunc() {
|
helpFunc() {
|
||||||
echo "::: Disable client conf profiles"
|
echo "::: Disable client conf profiles"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
setupVars="/etc/pivpn/wireguard/setupVars.conf"
|
setupVars="/etc/pivpn/wireguard/setupVars.conf"
|
||||||
|
|
||||||
|
err() {
|
||||||
|
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
|
||||||
|
}
|
||||||
|
|
||||||
if [[ ! -f "${setupVars}" ]]; then
|
if [[ ! -f "${setupVars}" ]]; then
|
||||||
err "::: Missing setup vars file!"
|
err "::: Missing setup vars file!"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -10,10 +14,6 @@ fi
|
||||||
# shellcheck disable=SC1090
|
# shellcheck disable=SC1090
|
||||||
source "${setupVars}"
|
source "${setupVars}"
|
||||||
|
|
||||||
err() {
|
|
||||||
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
helpFunc() {
|
helpFunc() {
|
||||||
echo "::: Enables client conf profiles"
|
echo "::: Enables client conf profiles"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
|
|
|
@ -8,6 +8,10 @@ setupVars="/etc/pivpn/wireguard/setupVars.conf"
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
userGroup="${install_user}:${install_user}"
|
userGroup="${install_user}:${install_user}"
|
||||||
|
|
||||||
|
err() {
|
||||||
|
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
|
||||||
|
}
|
||||||
|
|
||||||
if [[ ! -f "${setupVars}" ]]; then
|
if [[ ! -f "${setupVars}" ]]; then
|
||||||
err "::: Missing setup vars file!"
|
err "::: Missing setup vars file!"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -16,10 +20,6 @@ fi
|
||||||
# shellcheck disable=SC1090
|
# shellcheck disable=SC1090
|
||||||
source "${setupVars}"
|
source "${setupVars}"
|
||||||
|
|
||||||
err() {
|
|
||||||
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
helpFunc() {
|
helpFunc() {
|
||||||
echo "::: Create a client conf profile"
|
echo "::: Create a client conf profile"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
setupVars="/etc/pivpn/wireguard/setupVars.conf"
|
setupVars="/etc/pivpn/wireguard/setupVars.conf"
|
||||||
|
|
||||||
|
err() {
|
||||||
|
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
|
||||||
|
}
|
||||||
|
|
||||||
if [[ ! -f "${setupVars}" ]]; then
|
if [[ ! -f "${setupVars}" ]]; then
|
||||||
err "::: Missing setup vars file!"
|
err "::: Missing setup vars file!"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -10,10 +14,6 @@ fi
|
||||||
# shellcheck disable=SC1090
|
# shellcheck disable=SC1090
|
||||||
source "${setupVars}"
|
source "${setupVars}"
|
||||||
|
|
||||||
err() {
|
|
||||||
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
helpFunc() {
|
helpFunc() {
|
||||||
echo "::: Remove a client conf profile"
|
echo "::: Remove a client conf profile"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
|
|
Loading…
Reference in a new issue