From d05b07fee3d06cfd6f06d21b0ba60cd6a5223c0c Mon Sep 17 00:00:00 2001 From: billz Date: Wed, 7 Apr 2021 08:46:26 +0100 Subject: [PATCH] Append WG option if undefined --- installers/common.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/installers/common.sh b/installers/common.sh index 26f3e92f..238c3bf4 100755 --- a/installers/common.sh +++ b/installers/common.sh @@ -366,7 +366,11 @@ function _install_wireguard() { echo "Enabling wg-quick@wg0" sudo systemctl enable wg-quick@wg0 || _install_status 1 "Failed to enable wg-quick service" echo "Enabling WireGuard management option" - sudo sed -i "s/\('RASPI_WIREGUARD_ENABLED', \)false/\1true/g" "$webroot_dir/includes/config.php" || _install_status 1 "Unable to modify config.php" + if grep -q 'RASPI_WIREGUARD_ENABLED' "$webroot_dir/includes/config.php"; then + sudo sed -i "s/\('RASPI_WIREGUARD_ENABLED', \)false/\1true/g" "$webroot_dir/includes/config.php" || _install_status 1 "Unable to modify config.php" + else + sudo sed -i "/define('RASPI_OPENVPN_ENABLED', true);/a define('RASPI_WIREGUARD_ENABLED', true);" "$webroot_dir/includes/config.php" || _install_status 1 "Unable to modify config.php" + fi _install_status 0 }