From cba9aaf8a57a1b73492dde4bef35b52c3256bf84 Mon Sep 17 00:00:00 2001 From: pvincent Date: Wed, 2 Jul 2025 22:37:52 +0400 Subject: [PATCH] execute as root or use `sudo` --- README.md | 5 +++++ bin/apply_auth_remote_ssh.bash | 7 +++++-- bin/export.bash | 4 +++- bin/import.bash | 3 +++ bin/purge.bash | 4 +++- debian/install.bash | 5 +++++ debian/install_zourit_style.bash | 11 +++++++++-- 7 files changed, 33 insertions(+), 6 deletions(-) mode change 100644 => 100755 bin/purge.bash mode change 100644 => 100755 debian/install.bash diff --git a/README.md b/README.md index 0b83e5e..43d0d20 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ # sympa-utils utilities for SYMPA + +## usage + +* # prepend by `sudo` +* sudo bin/purge.bash diff --git a/bin/apply_auth_remote_ssh.bash b/bin/apply_auth_remote_ssh.bash index da65e87..760ba9e 100755 --- a/bin/apply_auth_remote_ssh.bash +++ b/bin/apply_auth_remote_ssh.bash @@ -1,13 +1,16 @@ #!/usr/bin/env bash +# execute as root or use `sudo` +[[ $(id -u) != 0 ]] && exec sudo $(dirname "$0")/$(basename "$0") + # changes in /etc/sympa/auth.conf -sed -i 's/.*host 192.168.1.254:389.*/ host 127.0.0.1:389 # remote connection through SSH/' /etc/sympa/auth.conf +sed -i 's/.*host 192.168.1.254:389.*/\thost 127.0.0.1:389/' /etc/sympa/auth.conf # start SSH port translation if needed if ! ss -tln | grep -q 127.0.0.1:389; then ssh -fN listes.artcode.re -L 389:192.168.1.254:389 - echo 'SSH port translation 389 is now active!' systemctl restart wwsympa.socket + echo 'SSH port translation 389 is now active!' else echo 'SSH already enabled!' fi diff --git a/bin/export.bash b/bin/export.bash index 666307e..577d676 100755 --- a/bin/export.bash +++ b/bin/export.bash @@ -39,6 +39,8 @@ function export { ### MAIN -set -Eeu +# execute as root or use `sudo` +[[ $(id -u) != 0 ]] && exec sudo $(dirname "$0")/$(basename "$0") +set -Eeu export diff --git a/bin/import.bash b/bin/import.bash index 864b4bb..bebac5a 100755 --- a/bin/import.bash +++ b/bin/import.bash @@ -129,6 +129,9 @@ function import { ## main +# execute as root or use `sudo` +[[ $(id -u) != 0 ]] && exec sudo $(dirname "$0")/$(basename "$0") + set -Eeu assert_file $* import diff --git a/bin/purge.bash b/bin/purge.bash old mode 100644 new mode 100755 index d5a3d32..c14e6a5 --- a/bin/purge.bash +++ b/bin/purge.bash @@ -82,6 +82,8 @@ function export { ### MAIN -set -Eeu +# execute as root or use `sudo` +[[ $(id -u) != 0 ]] && exec sudo $(dirname "$0")/$(basename "$0") +set -Eeu purge diff --git a/debian/install.bash b/debian/install.bash old mode 100644 new mode 100755 index 120ba33..ed622cc --- a/debian/install.bash +++ b/debian/install.bash @@ -1,3 +1,8 @@ #!/usr/bin/env bash +## MAIN + +# execute as root or use `sudo` +[[ $(id -u) != 0 ]] && exec sudo $(dirname "$0")/$(basename "$0") + echo TODO... \ No newline at end of file diff --git a/debian/install_zourit_style.bash b/debian/install_zourit_style.bash index a72e577..89372c0 100755 --- a/debian/install_zourit_style.bash +++ b/debian/install_zourit_style.bash @@ -1,5 +1,10 @@ #!/usr/bin/env bash +## MAIN + +# execute as root or use `sudo` +[[ $(id -u) != 0 ]] && exec sudo $(dirname "$0")/$(basename "$0") + # changes in /usr/share/sympa/lib/Sympa/Config/Schema.pm sed -i "s/.*005ab2.*/ default => '#ad0c78', # '#005ab2' replaced by ZOURIT-COLOR-1/" /usr/share/sympa/lib/Sympa/Config/Schema.pm sed -i "s/.*004b94.*/ default => '#1f2937', # '#004b94' replaced by ZOURIT-COLOR-2/" /usr/share/sympa/lib/Sympa/Config/Schema.pm @@ -23,5 +28,7 @@ for i in /var/lib/sympa/css/*; do fi done -[[ $socket_restart == true ]] && systemctl restart wwsympa.socket && echo "wwsympa restarted with fresh styles" -true +if $socket_restart; then + systemctl restart wwsympa.socket + echo "wwsympa restarted with fresh styles" +fi