This commit is contained in:
parent
314560c125
commit
d231cdd499
1 changed files with 25 additions and 4 deletions
29
menhera.sh
29
menhera.sh
|
@ -12,15 +12,36 @@ NEWROOT=""
|
||||||
# fix possible PATH problems
|
# fix possible PATH problems
|
||||||
export PATH="$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
export PATH="$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
|
|
||||||
|
menhera::reset_sshd_config() {
|
||||||
|
cat > /etc/ssh/sshd_config <<EOF
|
||||||
|
PermitRootLogin yes
|
||||||
|
AcceptEnv LANG LC_*
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
# environment compatibility
|
# environment compatibility
|
||||||
menhera::__compat_restart_ssh() {
|
menhera::__compat_restart_ssh() {
|
||||||
if [ -x "$(command -v systemctl)" ]; then
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl restart ssh
|
if ! systemctl restart ssh; then
|
||||||
|
echo "SSH daemon start failed, try resetting config..."
|
||||||
|
menhera::reset_sshd_config
|
||||||
|
if ! systemctl restart ssh; then
|
||||||
|
echo "SSH daemon fail to start, dropping you to a shell..."
|
||||||
|
sh
|
||||||
|
fi
|
||||||
|
fi
|
||||||
elif [ -x "$(command -v service)" ]; then
|
elif [ -x "$(command -v service)" ]; then
|
||||||
service ssh restart
|
if ! service ssh restart; then
|
||||||
|
echo "SSH daemon start failed, try resetting config..."
|
||||||
|
menhera::reset_sshd_config
|
||||||
|
if ! service ssh restart; then
|
||||||
|
echo "SSH daemon fail to start, dropping you to a shell..."
|
||||||
|
sh
|
||||||
|
fi
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "ERROR: Cannot restart SSH server" >&2
|
echo "ERROR: Cannot restart SSH server, init system not recoginzed" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -31,7 +52,7 @@ menhera::__compat_reload_init() {
|
||||||
elif [ -x "$(command -v telinit)" ]; then
|
elif [ -x "$(command -v telinit)" ]; then
|
||||||
telinit u
|
telinit u
|
||||||
else
|
else
|
||||||
echo "ERROR: Cannot re-exec init" >&2
|
echo "ERROR: Cannot re-exec init, init system not recoginzed" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue