Simplify code / indentation levels

This commit is contained in:
Alexandre Aubin 2018-11-28 21:03:28 +00:00
parent 4db65682eb
commit 0576b17442

View file

@ -7,10 +7,11 @@ set -e
do_pre_regen() {
pending_dir=$1
cd /usr/share/yunohost/templates/ssh
# If the (legacy) 'from_script' flag is here,
# we won't touch anything in the ssh config.
[[ ! -f /etc/yunohost/from_script ]] || return
# Don't overwrite configuration if from_script
if [[ ! -f /etc/yunohost/from_script ]]; then
cd /usr/share/yunohost/templates/ssh
# do not listen to IPv6 if unavailable
[[ -f /proc/net/if_inet6 ]] && ipv6_enabled=true || ipv6_enabled=false
@ -25,19 +26,23 @@ do_pre_regen() {
export ssh_keys
export ipv6_enabled
ynh_render_template "sshd_config" "${pending_dir}/etc/ssh/sshd_config"
fi
}
do_post_regen() {
regen_conf_files=$1
if [[ ! -f /etc/yunohost/from_script ]]; then
if [[ -n "$regen_conf_files" ]];
then
sudo service ssh restart
# If the (legacy) 'from_script' flag is here,
# we won't touch anything in the ssh config.
[[ ! -f /etc/yunohost/from_script ]] || return
# If no file changed, there's nothing to do
[[ -n "$regen_conf_files" ]] || return
# Enforce permissions for /etc/ssh/sshd_config
chown root:root "/etc/ssh/sshd_config"
chmod 644 "/etc/ssh/sshd_config"
fi
fi
systemctl restart ssh
}
FORCE=${2:-0}