riddhiman commited on
Commit
b170d20
·
verified ·
1 Parent(s): 0dc29eb

Rename startup.sh to upload_world.sh

Browse files
Files changed (2) hide show
  1. startup.sh +0 -32
  2. upload_world.sh +18 -0
startup.sh DELETED
@@ -1,32 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Setup Git configuration
4
- git config --global user.name "${GIT_USERNAME}"
5
- git config --global user.email "${GIT_EMAIL}"
6
-
7
- # Git authentication via HTTPS and Personal Access Token
8
- git config --global credential.helper 'cache --timeout=300'
9
- echo "https://${GIT_USERNAME}:${GIT_AUTH_TOKEN}@${GIT_REPO#https://}"
10
-
11
- # Clone or pull latest Minecraft world(s) data
12
- if [ -d ./world ]; then
13
- echo "World directory exists. Pulling latest changes."
14
- cd ./world && git pull origin ${GIT_BRANCH}
15
- cd ..
16
- else
17
- echo "Cloning worlds repository."
18
- git clone ${GIT_REPO} -b ${GIT_BRANCH} ./world
19
- fi
20
-
21
- # Assuming nether and the_end are separate directories you want to manage
22
- if [ ! -d ./world_nether ]; then
23
- git clone ${GIT_REPO} -b ${GIT_BRANCH}_nether ./world_nether
24
- fi
25
- if [ ! -d ./world_the_end ]; then
26
- git clone ${GIT_REPO} -b ${GIT_BRANCH}_the_end ./world_the_end
27
- fi
28
-
29
- # Start the Minecraft server and trap the stop signal to run the upload script
30
- trap './shutdown.sh' SIGTERM
31
-
32
- java ${JAVA_OPTS} -jar server.jar --nogui --port 7860
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
upload_world.sh ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ GIT_USERNAME="$GIT_USERNAME"
4
+ GIT_EMAIL="$GIT_EMAIL"
5
+ GIT_REPO="$GIT_REPO"
6
+ GIT_BRANCH="$GIT_BRANCH"
7
+ GIT_AUTH_TOKEN="$GIT_AUTH_TOKEN"
8
+
9
+ cd /minecraft/world || exit
10
+ git init
11
+ git config --global user.email "$GIT_EMAIL"
12
+ git config --global user.name "$GIT_USERNAME"
13
+ git remote add origin "$GIT_REPO"
14
+ git fetch
15
+ git reset --soft "origin/$GIT_BRANCH"
16
+ git add -A
17
+ git commit -m "Latest world backup"
18
+ git push -u "https://$GIT_AUTH_TOKEN@$GIT_REPO" "HEAD:$GIT_BRANCH" --force