Skip to content

Commit 4a557e0

Browse files
reverted the changes for setup.sh
1 parent 8064470 commit 4a557e0

File tree

1 file changed

+61
-78
lines changed

1 file changed

+61
-78
lines changed

setup.sh

Lines changed: 61 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ set_auto_update() {
111111
# Prompt user for input
112112
echo "Do you want to enable systemguard_auto_update? (true/false)"
113113
echo "This will enable automatic updates for SystemGuard."
114-
read -p "Enter your choice: true/false: " auto_update
114+
read -p "Enter your choice: " auto_update
115115

116116
# Validate input
117117
if [[ "$auto_update" != "true" && "$auto_update" != "false" ]]; then
@@ -230,6 +230,7 @@ add_cron_job() {
230230
local script_path=$(find "$EXTRACT_DIR" -name dashboard.sh)
231231
local cron_job="* * * * * /bin/bash $script_path >> $log_dir/systemguard_cron.log 2>&1"
232232

233+
# Create log directory with error handling
233234
if [ $? -ne 0 ]; then
234235
log "CRITICAL" "Failed to create log directory: $log_dir"
235236
exit 1
@@ -535,8 +536,16 @@ install_from_release() {
535536
log "Server may take a few minutes to start. If you face any issues, try restarting the server."
536537
}
537538

538-
# Function to select the installation method
539-
select_install_method() {
539+
display_credentials() {
540+
log "INFO" "You can now login to the server using the following credentials:"
541+
log "INFO" "Username: $SYSTEMGUARD_USERNAME"
542+
log "INFO" "Password: $SYSTEMGUARD_PASSWORD"
543+
}
544+
545+
# Install function
546+
install() {
547+
log "Starting installation of $APP_NAME..."
548+
echo ""
540549
echo "Do you want to install from a Git repository or a specific release?"
541550
echo "|----------------------------------------------------|"
542551
echo "| 1. Git repository |"
@@ -545,22 +554,6 @@ select_install_method() {
545554
echo "Enter the number of your choice:"
546555
read -r INSTALL_METHOD
547556

548-
case $INSTALL_METHOD in
549-
1) install_from_git ;;
550-
2) install_from_release ;;
551-
*) log "Invalid installation method. Please choose '1' for Git repository or '2' for Release."; exit 1 ;;
552-
esac
553-
}
554-
555-
display_credentials() {
556-
log "INFO" "You can now login to the server using the following credentials:"
557-
log "INFO" "Username: $SYSTEMGUARD_USERNAME"
558-
log "INFO" "Password: $SYSTEMGUARD_PASSWORD"
559-
}
560-
561-
# Install function
562-
install () {
563-
select_install_method
564557
case $INSTALL_METHOD in
565558
1)
566559
install_from_git
@@ -677,7 +670,6 @@ show_server_logs() {
677670
echo ""
678671

679672
cd $EXTRACT_DIR/$APP_NAME-*/
680-
echo $EXTRACT_DIR/$APP_NAME-*/
681673
log_file=$(find . -name "app_debug.log" | head -n 1)
682674
echo "log file: $log_file"
683675
if [ -f "$log_file" ]; then
@@ -688,21 +680,6 @@ show_server_logs() {
688680
fi
689681
}
690682

691-
# app logs
692-
post_installation_logs() {
693-
log "INFO" "Press Ctrl+C to exit."
694-
echo ""
695-
echo "--- post installation Logs ---"
696-
echo ""
697-
echo "log file: $FLASK_LOG_FILE"
698-
if [ -f "$FLASK_LOG_FILE" ]; then
699-
log "Server log file: $FLASK_LOG_FILE"
700-
tail -100f "$FLASK_LOG_FILE"
701-
else
702-
log "No logs found at $FLASK_LOG_FILE."
703-
fi
704-
}
705-
706683
# installation logs
707684
show_installer_logs() {
708685
log "INFO" "Press Ctrl+C to exit."
@@ -792,47 +769,53 @@ fix() {
792769
}
793770

794771
# Display help
795-
display_help() {
796-
echo "$APP_NAME Installer and Manager"
797-
echo ""
798-
echo "Usage: $EXECUTABLE_APP_NAME [command]"
772+
show_help() {
773+
echo "$APP_NAME Installer"
799774
echo ""
800-
echo "Commands:"
801-
echo " --install Install $APP_NAME and configure all dependencies."
802-
echo " Sets up the environment and starts the application."
775+
echo "Usage: $EXECUTABLE_APP_NAME [options]"
803776
echo ""
804-
echo " --uninstall Completely remove $APP_NAME and all related files."
777+
echo "Options:"
778+
echo " --install Install $APP_NAME and set up all necessary dependencies."
779+
echo " This will configure the environment and start the application."
805780
echo ""
806-
echo " --repair Repair $APP_NAME installation issues."
807-
echo " Fixes any installation errors and restarts the server."
781+
echo " --uninstall Uninstall $APP_NAME completely."
782+
echo " This will remove the application and all associated files."
808783
echo ""
809-
echo " --restore-backup Restore $APP_NAME from a backup."
810-
echo " Recover data or settings from a previous backup."
784+
echo " --fix Fix the $APP_NAME installation errors."
785+
echo " This will fix any issues with the installation and restart the server."
786+
echo ""
787+
echo " --restore Restore $APP_NAME from a backup."
788+
echo " Use this option to recover data or settings from a previous backup."
811789
echo ""
812-
echo " --run-load-test Perform load testing using Locust for $APP_NAME."
813-
echo " Simulates multiple users to test application performance."
790+
echo " --load-test Start Locust load testing for $APP_NAME."
791+
echo " This will initiate performance testing to simulate multiple users."
814792
echo ""
815-
echo " --check-status Display the current status of $APP_NAME."
816-
echo " Shows whether the application is installed, running, or encountering issues."
793+
echo " --status Check the status of $APP_NAME installation."
794+
echo " Displays whether $APP_NAME is installed, running, or if there are any issues."
817795
echo ""
818-
echo " --perform-health-check Check the health of $APP_NAME at $HOST_URL."
819-
echo " Ensures the application is running properly and responding."
796+
echo " --health-check Perform a health check on $HOST_URL."
797+
echo " Verifies that the application is running correctly and responding to requests."
820798
echo ""
821-
echo " --clean-old-backups Remove all $APP_NAME backup files."
822-
echo " Deletes stored backups to free up disk space."
799+
echo " --clean-backups Clean up all backups of $APP_NAME."
800+
echo " This will delete all saved backup files to free up space."
823801
echo ""
824-
echo " --view-server-logs Display recent server logs for $APP_NAME."
825-
echo " Helps diagnose server issues. Use Ctrl+C to exit."
802+
echo " --logs Show server logs for $APP_NAME."
803+
echo " Displays the latest server logs, which can help in troubleshooting issues."
804+
echo " Press Ctrl+C to exit the log viewing session."
826805
echo ""
827-
echo " --view-install-logs Show installation logs for $APP_NAME."
828-
echo " Provides details on the installation process. Use Ctrl+C to exit."
806+
echo " --installation-logs Show installer logs for $APP_NAME."
807+
echo " Displays the logs generated during the installation process."
808+
echo " Press Ctrl+C to exit the log viewing session."
829809
echo ""
830-
echo " --stop-server Stop the currently running $APP_NAME server."
810+
echo " --server-stop Stop the $APP_NAME server."
811+
echo " This will stop the running server instance."
831812
echo ""
832-
echo " --update-dependencies Update $APP_NAME dependencies."
833-
echo " Ensures all dependencies are up-to-date."
813+
echo " --update-dependencies"
814+
echo " Update the dependencies of the $APP_NAME."
815+
echo " This will update the dependencies of the application."
834816
echo ""
835-
echo " --help Display this help message with available commands."
817+
echo " --help Display this help message."
818+
echo " Shows information about all available options and how to use them."
836819
}
837820

838821

@@ -841,35 +824,35 @@ for arg in "$@"; do
841824
case $arg in
842825
--install) ACTION="install" ;;
843826
--uninstall) ACTION="uninstall" ;;
844-
--repair) ACTION="fix" ;;
845-
--restore-backup) ACTION="restore" ;;
846-
--run-load-test) ACTION="load_test" ;;
847-
--check-status) ACTION="check_status" ;;
848-
--perform-health-check) ACTION="health_check" ;;
849-
--clean-old-backups) ACTION="cleanup_backups" ;;
850-
--view-server-logs) ACTION="logs" ;;
851-
--view-install-logs) ACTION="installation-logs" ;;
852-
--stop-server) ACTION="stop_server" ;;
853-
--update-dependencies) ACTION="update_dependencies" ;;
854-
--help) ACTION="help" ;;
855-
*) echo "Unknown option: $arg"; ACTION="help"; ;;
827+
--restore) ACTION="restore" ;;
828+
--load-test) ACTION="load_test" ;;
829+
--status) ACTION="check_status" ;;
830+
--health-check) ACTION="health_check" ;;
831+
--clean-backups) ACTION="cleanup_backups" ;;
832+
--logs) show_server_logs; exit 0 ;;
833+
--installation-logs) show_installer_logs; exit 0 ;;
834+
--server-stop) stop_server; exit 0 ;;
835+
--fix) fix; exit 0 ;;
836+
--update-dependencies) update_dependencies; exit 0 ;;
837+
--help) show_help; exit 0 ;;
838+
*) echo "Unknown option: $arg"; show_help; exit 1 ;;
856839
esac
857840
done
858841

859842
# Execute based on the action specified
860843
case $ACTION in
861844
install) install ;;
862845
uninstall) uninstall ;;
863-
fix) fix ;;
864846
restore) restore ;;
865847
load_test) load_test ;;
848+
install_latest) install_latest ;;
866849
check_status) check_status ;;
867850
health_check) health_check ;;
868851
cleanup_backups) cleanup_backups ;;
852+
stop_server) stop_server ;;
869853
logs) show_server_logs ;;
870854
installation-logs) show_installer_logs ;;
871-
stop_server) stop_server ;;
855+
fix) fix ;;
872856
update_dependencies) update_dependencies ;;
873-
help) display_help ;;
874857
*) echo "No action specified. Use --help for usage information." ;;
875858
esac

0 commit comments

Comments
 (0)