mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Simplify code / indentation levels
This commit is contained in:
parent
4db65682eb
commit
0576b17442
1 changed files with 29 additions and 24 deletions
|
@ -5,39 +5,44 @@ set -e
|
||||||
. /usr/share/yunohost/helpers.d/utils
|
. /usr/share/yunohost/helpers.d/utils
|
||||||
|
|
||||||
do_pre_regen() {
|
do_pre_regen() {
|
||||||
pending_dir=$1
|
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
|
cd /usr/share/yunohost/templates/ssh
|
||||||
if [[ ! -f /etc/yunohost/from_script ]]; then
|
|
||||||
|
|
||||||
# do not listen to IPv6 if unavailable
|
# do not listen to IPv6 if unavailable
|
||||||
[[ -f /proc/net/if_inet6 ]] && ipv6_enabled=true || ipv6_enabled=false
|
[[ -f /proc/net/if_inet6 ]] && ipv6_enabled=true || ipv6_enabled=false
|
||||||
|
|
||||||
ssh_keys=$(ls /etc/ssh/ssh_host_{ed25519,rsa,ecdsa}_key 2>/dev/null)
|
ssh_keys=$(ls /etc/ssh/ssh_host_{ed25519,rsa,ecdsa}_key 2>/dev/null)
|
||||||
|
|
||||||
# Support legacy setting (this setting might be disabled by a user during a migration)
|
# Support legacy setting (this setting might be disabled by a user during a migration)
|
||||||
if [[ "$(yunohost settings get 'service.ssh.allow_deprecated_dsa_hostkey')" == "True" ]]; then
|
if [[ "$(yunohost settings get 'service.ssh.allow_deprecated_dsa_hostkey')" == "True" ]]; then
|
||||||
ssh_keys="$ssh_keys $(ls /etc/ssh/ssh_host_dsa_key 2>/dev/null)"
|
ssh_keys="$ssh_keys $(ls /etc/ssh/ssh_host_dsa_key 2>/dev/null)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export ssh_keys
|
export ssh_keys
|
||||||
export ipv6_enabled
|
export ipv6_enabled
|
||||||
ynh_render_template "sshd_config" "${pending_dir}/etc/ssh/sshd_config"
|
ynh_render_template "sshd_config" "${pending_dir}/etc/ssh/sshd_config"
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
do_post_regen() {
|
do_post_regen() {
|
||||||
regen_conf_files=$1
|
regen_conf_files=$1
|
||||||
if [[ ! -f /etc/yunohost/from_script ]]; then
|
|
||||||
if [[ -n "$regen_conf_files" ]];
|
# If the (legacy) 'from_script' flag is here,
|
||||||
then
|
# we won't touch anything in the ssh config.
|
||||||
sudo service ssh restart
|
[[ ! -f /etc/yunohost/from_script ]] || return
|
||||||
chown root:root "/etc/ssh/sshd_config"
|
|
||||||
chmod 644 "/etc/ssh/sshd_config"
|
# If no file changed, there's nothing to do
|
||||||
fi
|
[[ -n "$regen_conf_files" ]] || return
|
||||||
fi
|
|
||||||
|
# Enforce permissions for /etc/ssh/sshd_config
|
||||||
|
chown root:root "/etc/ssh/sshd_config"
|
||||||
|
chmod 644 "/etc/ssh/sshd_config"
|
||||||
|
|
||||||
|
systemctl restart ssh
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCE=${2:-0}
|
FORCE=${2:-0}
|
||||||
|
|
Loading…
Add table
Reference in a new issue