mirror of
https://github.com/wlinator/luminara.git
synced 2024-10-02 20:23:12 +00:00
Add bash script for automation
In the future this script will run on a /restart or /update command, so I don't have to manually pull Git changes & restart the bot on the server.
This commit is contained in:
parent
1ec6792636
commit
f6290ea966
1 changed files with 42 additions and 0 deletions
42
racu_update.sh
Normal file
42
racu_update.sh
Normal file
|
@ -0,0 +1,42 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Change to the project directory
|
||||
# cd .
|
||||
|
||||
# Stash any local changes
|
||||
git stash
|
||||
|
||||
# Fetch the latest changes from the remote repository
|
||||
git fetch
|
||||
|
||||
# Get the current branch
|
||||
current_branch=$(git symbolic-ref --short HEAD)
|
||||
|
||||
# Check if the branch is behind the remote branch
|
||||
if [ -n "$(git rev-list --left-only --count origin/$current_branch...HEAD)" ]; then
|
||||
# Pull the latest changes
|
||||
git pull
|
||||
|
||||
# Check if there are any merge conflicts
|
||||
if [ -n "$(git ls-files --unmerged)" ]; then
|
||||
echo "Merge conflicts detected. Please resolve them manually."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "No new changes found in the remote repository."
|
||||
fi
|
||||
|
||||
# Restart the pm2 process
|
||||
pm2 restart Racu.Core 1>/dev/null 2>&1
|
||||
|
||||
# Check the pm2 process status
|
||||
pm2_status=$(pm2 jlist | jq -r '.[] | select(.name == "Racu.Core") | .pm2_env.status')
|
||||
|
||||
if [ "$pm2_status" = "online" ]; then
|
||||
echo "Process restarted successfully."
|
||||
else
|
||||
echo "Failed to restart the process. Check the pm2 logs for more information."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
Loading…
Reference in a new issue