From 5bb722a83d76fcb67d75419113b8a0d79ecbfb68 Mon Sep 17 00:00:00 2001 From: Anthony Date: Mon, 30 Oct 2023 21:21:51 +0800 Subject: [PATCH] Added Uninstall --- add-sftp.sh | 3 --- install-sftp.sh | 12 ------------ manifest.jps | 12 ++++++++++++ 3 files changed, 12 insertions(+), 15 deletions(-) delete mode 100644 install-sftp.sh diff --git a/add-sftp.sh b/add-sftp.sh index ca8464d..b5e95a2 100644 --- a/add-sftp.sh +++ b/add-sftp.sh @@ -1,8 +1,6 @@ #!/bin/bash echo "Script started" >> /home/jelastic/add-sftp-user-addon/script_output.log - -# Generate random username and password USERNAME="user$(shuf -i 10000-99999 -n 1)" PASSWORD=$(openssl rand -base64 12) @@ -28,6 +26,5 @@ usermod -aG litespeed,root $USERNAME chown $USERNAME:root $ROOT_DIRECTORY chmod 775 $ROOT_DIRECTORY -# Get the hostname HOSTNAME=$(hostname -f) echo "Script completed for user $USERNAME with hostname $HOSTNAME" >> /home/jelastic/add-sftp-user-addon/script_output.log diff --git a/install-sftp.sh b/install-sftp.sh deleted file mode 100644 index 5eefa39..0000000 --- a/install-sftp.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -# Root User -sudo su -# Update sshd_config -echo -e "\nMatch User user*\nPasswordAuthentication yes" >> /etc/ssh/sshd_config -# Adjust permissions -chown root:root /var/www/webroot/ROOT -chmod 755 /var/www/webroot/ROOT - -#Restart SSH daemon -sudo systemctl restart sshd \ No newline at end of file diff --git a/manifest.jps b/manifest.jps index 1d504a8..6c386dd 100644 --- a/manifest.jps +++ b/manifest.jps @@ -45,6 +45,8 @@ onInstall: commands: - systemctl restart sshd user: root + - api: environment.control.RestartContainer + nodeGroup: cp - return: installSuccess actions: @@ -56,7 +58,17 @@ actions: return: sftpError - return: sftpSuccess +onUninstall: + - cmd[cp]: + commands: + - rm -rf /home/jelastic/add-sftp-user-addon/ + user: root + - return: uninstallSuccess + responses: + uninstallSuccess: + type: success + message: "Uninstalled Successfully" installSuccess: type: success message: "Installed Successfully"