mirror of
https://github.com/pivpn/pivpn.git
synced 2025-04-25 08:40:10 +00:00
refactor: improve code style
Improve the code style of some pieces of code
This commit is contained in:
parent
9a7b7dfe72
commit
dda4d99f10
9 changed files with 54 additions and 128 deletions
|
@ -58,9 +58,7 @@ listClients() {
|
|||
printf "- %s\n" "${array[9]}"
|
||||
done < "${STATUS_LOG}"
|
||||
else
|
||||
awk \
|
||||
-F' ' \
|
||||
-v s='CLIENT_LIST' \
|
||||
awk -F ' ' -v s='CLIENT_LIST' \
|
||||
'$1 == s {
|
||||
print $2"\t\t"$3"\t"$4"\t"$5"\t\t"$6"\t\t"$8" "$9" "$11" - "$10"\n"
|
||||
}' \
|
||||
|
|
|
@ -443,8 +443,7 @@ echo "tls Private Key found: ${TA}"
|
|||
|
||||
# Next append the client Public Cert
|
||||
echo "<cert>"
|
||||
sed \
|
||||
-n \
|
||||
sed -n \
|
||||
-e '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' \
|
||||
< "issued/${NAME}${CRT}"
|
||||
echo "</cert>"
|
||||
|
@ -517,8 +516,7 @@ for i in {2..254}; do
|
|||
# disabling SC2514, variable sourced externaly
|
||||
# shellcheck disable=SC2154
|
||||
if [[ -z "$(ls -A /etc/openvpn/ccd)" ]] \
|
||||
|| ! find /etc/openvpn/ccd \
|
||||
-type f \
|
||||
|| ! find /etc/openvpn/ccd -type f \
|
||||
-exec grep -q "${NET_REDUCED}.${i}" {} +; then
|
||||
COUNT="${i}"
|
||||
echo -n "ifconfig-push ${NET_REDUCED}.${i}" >> /etc/openvpn/ccd/"${NAME}"
|
||||
|
|
|
@ -22,8 +22,7 @@ echo -n "Branch: "
|
|||
|
||||
git --git-dir /usr/local/src/pivpn/.git rev-parse --abbrev-ref HEAD
|
||||
git \
|
||||
--git-dir /usr/local/src/pivpn/.git log \
|
||||
-n 1 \
|
||||
--git-dir /usr/local/src/pivpn/.git log -n 1 \
|
||||
--format='Commit: %H%nAuthor: %an%nDate: %ad%nSummary: %s'
|
||||
|
||||
printf "=============================================\n"
|
||||
|
|
|
@ -181,8 +181,7 @@ for ((ii = 0; ii < ${#CERTS_TO_REVOKE[@]}; ii++)); do
|
|||
if [[ -f /etc/pivpn/hosts.openvpn ]]; then
|
||||
sed \
|
||||
-e "\#${STATIC_IP} ${CERTS_TO_REVOKE[ii]}.pivpn#d" \
|
||||
-i \
|
||||
/etc/pivpn/hosts.openvpn
|
||||
-i /etc/pivpn/hosts.openvpn
|
||||
|
||||
if killall -SIGHUP pihole-FTL; then
|
||||
echo "::: Updated hosts file for Pi-hole"
|
||||
|
|
|
@ -37,8 +37,7 @@ if [[ "$(< /proc/sys/net/ipv4/ip_forward)" -eq 1 ]]; then
|
|||
echo ":: [OK] IP forwarding is enabled"
|
||||
else
|
||||
ERR=1
|
||||
read \
|
||||
-r \
|
||||
read -r \
|
||||
-p ":: [ERR] IP forwarding is not enabled, attempt fix now? [Y/n] " \
|
||||
REPLY
|
||||
|
||||
|
@ -98,8 +97,7 @@ if [[ "${USING_UFW}" -eq 0 ]]; then
|
|||
echo ":: [OK] Iptables INPUT rule set"
|
||||
else
|
||||
ERR=1
|
||||
read \
|
||||
-r \
|
||||
read -r \
|
||||
-p ":: [ERR] Iptables INPUT rule is not set, attempt fix now? [Y/n] " \
|
||||
REPLY
|
||||
|
||||
|
@ -219,8 +217,7 @@ else
|
|||
echo ":: [OK] Ufw input rule set"
|
||||
else
|
||||
ERR=1
|
||||
read \
|
||||
-r \
|
||||
read -r \
|
||||
-p ":: [ERR] Ufw input rule is not set, attempt fix now? [Y/n] " \
|
||||
REPLY
|
||||
|
||||
|
@ -240,8 +237,7 @@ else
|
|||
echo ":: [OK] Ufw forwarding rule set"
|
||||
else
|
||||
ERR=1
|
||||
read \
|
||||
-r \
|
||||
read -r \
|
||||
-p ":: [ERR] Ufw forwarding rule is not set, attempt fix now? [Y/n] " \
|
||||
REPLY
|
||||
|
||||
|
|
|
@ -358,13 +358,11 @@ removeAll() {
|
|||
${SUDO} unlink /usr/local/bin/pivpn
|
||||
|
||||
${SUDO} ln \
|
||||
-s \
|
||||
-T "${pivpnFilesDir}/scripts/${othervpn}/pivpn.sh" \
|
||||
-sT "${pivpnFilesDir}/scripts/${othervpn}/pivpn.sh" \
|
||||
/usr/local/bin/pivpn
|
||||
|
||||
${SUDO} ln \
|
||||
-s \
|
||||
-T "${pivpnFilesDir}/scripts/${othervpn}/bash-completion" \
|
||||
-sT "${pivpnFilesDir}/scripts/${othervpn}/bash-completion" \
|
||||
/etc/bash_completion.d/pivpn
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
|
|
|
@ -22,8 +22,7 @@ echo -n "Branch: "
|
|||
|
||||
git --git-dir /usr/local/src/pivpn/.git rev-parse --abbrev-ref HEAD
|
||||
git \
|
||||
--git-dir /usr/local/src/pivpn/.git log \
|
||||
-n 1 \
|
||||
--git-dir /usr/local/src/pivpn/.git log -n 1 \
|
||||
--format='Commit: %H%nAuthor: %an%nDate: %ad%nSummary: %s'
|
||||
|
||||
printf "=============================================\n"
|
||||
|
|
|
@ -109,8 +109,7 @@ for CLIENT_NAME in "${CLIENTS_TO_REMOVE[@]}"; do
|
|||
# Then remove the client matching the variables above
|
||||
sed \
|
||||
-e "\#${CLIENT_NAME} ${PUBLIC_KEY} ${CREATION_DATE} ${COUNT}#d" \
|
||||
-i \
|
||||
configs/clients.txt
|
||||
-i configs/clients.txt
|
||||
|
||||
# Remove the peer section from the server config
|
||||
sed_pattern="/### begin ${CLIENT_NAME} ###/,"
|
||||
|
@ -136,10 +135,7 @@ for CLIENT_NAME in "${CLIENTS_TO_REMOVE[@]}"; do
|
|||
rm "${CONFIG}"
|
||||
fi
|
||||
done < <(find "${install_home}" \
|
||||
-maxdepth 3 \
|
||||
-type f \
|
||||
-name '*.conf' \
|
||||
-print0)
|
||||
-maxdepth 3 -type f -name '*.conf' -print0)
|
||||
|
||||
((DELETED_COUNT++))
|
||||
echo "::: Successfully deleted ${CLIENT_NAME}"
|
||||
|
@ -152,8 +148,7 @@ for CLIENT_NAME in "${CLIENTS_TO_REMOVE[@]}"; do
|
|||
sed \
|
||||
-e "\#${NET_REDUCED}.${COUNT} ${CLIENT_NAME}.pivpn#d" \
|
||||
-e "\#${pivpnNETv6}${COUNT} ${CLIENT_NAME}.pivpn#d" \
|
||||
-i \
|
||||
/etc/pivpn/hosts.wireguard
|
||||
-i /etc/pivpn/hosts.wireguard
|
||||
|
||||
if killall -SIGHUP pihole-FTL; then
|
||||
echo "::: Updated hosts file for Pi-hole"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue