Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit

Permalink
fix: stop server before upgrading (daytonaio#639)
Browse files Browse the repository at this point in the history
Signed-off-by: Ezhil Shanmugham <ezhil930@gmail.com>
  • Loading branch information
ezhil56x authored Jun 6, 2024
1 parent e1e4e42 commit 5f4681f
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions hack/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,61 @@
VERSION=${DAYTONA_SERVER_VERSION:-"latest"}
BASE_URL=${DAYTONA_SERVER_DOWNLOAD_URL:-"https://download.daytona.io/daytona"}
DESTINATION=${DAYTONA_PATH:-"/usr/local/bin"}
CONFIRM_FLAG=false

# Check for the -y flag
for arg in "$@"; do
case $arg in
-y)
CONFIRM_FLAG=true
shift
;;
esac
done

# Print error message to stderr and exit
err() {
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
exit 1
}

# Stop the Daytona server if it is running
stop_daytona_server() {
if pgrep -x "daytona" > /dev/null; then
if [ "$CONFIRM_FLAG" = false ]; then
read -p "Daytona server is running. Do you want to stop it? (yes/no): " user_input < /dev/tty
case $user_input in
[Yy][Ee][Ss] )
CONFIRM_FLAG=true
;;
[Nn][Oo] )
echo "Please stop the Daytona server manually and rerun the script."
exit 0
;;
* )
echo "Invalid input. Please enter 'yes' or 'no'."
exit 1
;;
esac
fi

if [ "$CONFIRM_FLAG" = true ]; then
echo "Attempting to stop the Daytona server..."
if daytona server stop; then
continue
else
pkill -x "daytona"
fi
echo -e "Daytona server stopped.\n"
fi
fi
}

# Check if the Daytona server is running
stop_daytona_server

echo -e "Installing Daytona...\n"

# Check machine architecture
ARCH=$(uname -m)
# Check operating system
Expand Down

0 comments on commit 5f4681f

Please sign in to comment.