Skip to content

Commit

Permalink
hooks/conf_regen: Fix some shellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
Salamandar committed Dec 21, 2024
1 parent f841bca commit d1fd9f5
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions hooks/conf_regen/03-ssh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

set -e
# Exit hook on subcommand error or unset variable
set -Eeuo pipefail

. /usr/share/yunohost/helpers
# Source YNH helpers
# shellcheck source=../../helpers/helpers
source /usr/share/yunohost/helpers

do_pre_regen() {
pending_dir=$1
Expand All @@ -34,7 +37,11 @@ do_pre_regen() {
export ssh_keys=$(ls /etc/ssh/ssh_host_{ed25519,rsa,ecdsa}_key 2> /dev/null || true)

# do not listen to IPv6 if unavailable
[[ -f /proc/net/if_inet6 ]] && ipv6_enabled=true || ipv6_enabled=false
if [[ -f /proc/net/if_inet6 ]]; then
ipv6_enabled=true
else
ipv6_enabled=false
fi
export ipv6_enabled

ynh_render_template "sshd_config" "${pending_dir}/etc/ssh/sshd_config"
Expand All @@ -44,6 +51,7 @@ do_post_regen() {
regen_conf_files=$1

# If no file changed, there's nothing to do

[[ -n "$regen_conf_files" ]] || return 0

# Enforce permissions for /etc/ssh/sshd_config
Expand All @@ -53,4 +61,4 @@ do_post_regen() {
systemctl restart ssh
}

do_$1_regen ${@:2}
"do_$1_regen" "${@:2}"

0 comments on commit d1fd9f5

Please sign in to comment.