more prompts
This commit is contained in:
@@ -43,9 +43,19 @@ prompt_user() {
|
||||
}
|
||||
|
||||
update_prompt() {
|
||||
local msg="${1:-$full_prompt_msg}"
|
||||
local icon="$1"
|
||||
local msg="${2:-$full_prompt_msg}"
|
||||
|
||||
# \e[1A: Move up one line
|
||||
# \r: Move to start of line
|
||||
# \e[K: Clear to end of line
|
||||
echo -en "\e[1A\r\e[K"
|
||||
echo -e "$1 $msg $REPLY"
|
||||
|
||||
if [[ "$msg" != "$full_prompt_msg" ]]; then
|
||||
echo -e "$icon $msg"
|
||||
else
|
||||
echo -e "$icon $msg $REPLY"
|
||||
fi
|
||||
}
|
||||
|
||||
auto_update_prompt() {
|
||||
@@ -69,7 +79,7 @@ sign_host_cert() {
|
||||
}
|
||||
|
||||
|
||||
check_ssh_files() {
|
||||
check_ssh_config_files() {
|
||||
row_success() {
|
||||
local key="$1"
|
||||
local path="$2"
|
||||
@@ -171,38 +181,36 @@ EOF
|
||||
prompt_user "sshd config" "Do you want to configure sshd?"
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
install_cert_config
|
||||
restart_sshd
|
||||
update_prompt $GREEN_CHECK "Configured sshd"
|
||||
fi
|
||||
fi
|
||||
restart_sshd
|
||||
}
|
||||
|
||||
restart_sshd() {
|
||||
if systemctl is-active --quiet sshd; then
|
||||
local sshd_pid=$(systemctl show --property MainPID --value sshd)
|
||||
echo "Restarting sshd service..."
|
||||
systemctl restart sshd
|
||||
echo -e "$GREEN_CHECK Restarted sshd service on PID: $sshd_pid"
|
||||
else
|
||||
echo -e "$YELLOW_BANG Not running sshd service"
|
||||
read -p "Do you want to start sshd? (y/n) " -n 1 -r
|
||||
echo
|
||||
if ! systemctl is-active --quiet sshd; then
|
||||
prompt_user "sshd.service" "sshd.service is not active. Restart?"
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
systemctl start sshd
|
||||
echo -e "$GREEN_CHECK Started sshd"
|
||||
systemctl restart sshd
|
||||
local sshd_pid=$(systemctl show --property MainPID --value sshd)
|
||||
update_prompt $GREEN_CHECK "Restarted sshd.service on PID: $sshd_pid"
|
||||
fi
|
||||
else
|
||||
local sshd_pid=$(systemctl show --property MainPID --value sshd)
|
||||
echo -e "$GREEN_CHECK sshd.service is active on PID: $sshd_pid"
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
|
||||
# Run Process
|
||||
#
|
||||
|
||||
# check_cert_config "certs.conf"
|
||||
# check_ssh_files
|
||||
check_cert_config "certs.conf"
|
||||
echo
|
||||
check_ssh_config_files
|
||||
|
||||
# echo ""
|
||||
# echo "Host key fingerprint"
|
||||
# ssh_fingerprint hostkey
|
||||
echo
|
||||
echo "Host key fingerprint"
|
||||
ssh_fingerprint hostkey
|
||||
|
||||
|
||||
prompt_user
|
||||
# prompt_user
|
||||
# auto_update_prompt
|
||||
|
||||
Reference in New Issue
Block a user