@@ -5,23 +5,7 @@ exported_at: "2025-03-26T00:00:00+00:00"
5
5
docker_image : ghcr.io/parkervcp/yolks:nodejs_22
6
6
features :
7
7
- docker
8
- startup : |
9
- if [[ -d .git ]] && [[ {{AUTO_UPDATE}} == "1" ]]; then
10
- git pull;
11
- fi;
12
- if [[ ! -z ${NODE_PACKAGES} ]]; then
13
- pnpm add -g ${NODE_PACKAGES};
14
- fi;
15
- if [[ ! -d node_modules ]]; then
16
- pnpm install;
17
- fi;
18
- if [[ -f build.sh ]]; then
19
- chmod +x build.sh && ./build.sh;
20
- fi;
21
- if [[ ! -z ${ENVIRONMENT} ]]; then
22
- export NODE_ENV=${ENVIRONMENT};
23
- fi;
24
- {{STARTUP_CMD}}
8
+ startup : " {{STARTUP_CMD}}"
25
9
config :
26
10
files : {}
27
11
startup :
@@ -36,52 +20,24 @@ variables:
36
20
user_viewable : true
37
21
user_editable : true
38
22
rules : required|string
39
- - name : Auto Update
40
- description : Pull the latest changes from Git on startup.
41
- env_variable : AUTO_UPDATE
42
- default_value : " 1"
43
- user_viewable : true
44
- user_editable : true
45
- rules : required|boolean
46
- - name : Node Environment
47
- description : The Node environment to use.
48
- env_variable : ENVIRONMENT
49
- default_value : production
50
- user_viewable : true
51
- user_editable : true
52
- rules : required|string|in:production,development,staging,test
53
- - name : Additional Node Packages
54
- description : Additional Node packages to install globally. Separate with spaces.
55
- env_variable : NODE_PACKAGES
56
- default_value : " "
57
- user_viewable : true
58
- user_editable : true
59
- rules : nullable|string
60
- - name : Wipe Directory on Install
61
- description : Whether to wipe the directory when installing.
62
- env_variable : WIPE
63
- default_value : " 0"
64
- user_viewable : true
65
- user_editable : true
66
- rules : required|boolean
67
23
- name : GitHub Username
68
- description : The GitHub username for the repository to clone (leave default for template repository) .
24
+ description : The GitHub username for the repository.
69
25
env_variable : GITHUB_USERNAME
70
26
default_value : " enum314"
71
27
user_viewable : true
72
28
user_editable : true
73
29
rules : required|string
74
30
- name : GitHub Repository
75
- description : The GitHub repository name to clone (leave default for template repository) .
31
+ description : The GitHub repository name.
76
32
env_variable : GITHUB_REPOSITORY
77
33
default_value : " nemesis"
78
34
user_viewable : true
79
35
user_editable : true
80
36
rules : required|string
81
- - name : GitHub Branch
82
- description : The branch to clone from the repository .
83
- env_variable : GITHUB_BRANCH
84
- default_value : " main "
37
+ - name : GitHub Tag
38
+ description : The release tag to install (use 'latest' for the most recent release) .
39
+ env_variable : GITHUB_TAG
40
+ default_value : " latest "
85
41
user_viewable : true
86
42
user_editable : true
87
43
rules : required|string
@@ -99,58 +55,83 @@ install:
99
55
#
100
56
# Server Files: /mnt/server
101
57
apt update
102
- apt install -y git curl
58
+ apt install -y curl wget tar jq file unzip make gcc g++ python3 python3-dev python3-pip libtool
103
59
curl -fsSL https://get.pnpm.io/install.sh | sh -
104
60
105
61
# Set repository variables from egg
106
62
GITHUB_USER="${GITHUB_USERNAME:-enum314}"
107
63
REPOSITORY="${GITHUB_REPOSITORY:-nemesis}"
108
- BRANCH ="${GITHUB_BRANCH:-main }"
64
+ TAG ="${GITHUB_TAG:-latest }"
109
65
TOKEN="${GITHUB_TOKEN}"
110
66
111
- # Construct the repository URL
112
- if [ -z "$TOKEN" ]; then
113
- # Public repository
114
- SOURCE="https://github.com/${GITHUB_USER}/${REPOSITORY}.git"
115
- else
116
- # Private repository with token
117
- SOURCE="https://${TOKEN}@github.com/${GITHUB_USER}/${REPOSITORY}.git"
118
- fi
119
-
120
67
DEPLOY_DIR="/mnt/server"
121
68
122
69
# Make sure pterodactyl user can use pnpm
123
70
export PNPM_HOME="/usr/local/pnpm"
124
71
export PATH="$PNPM_HOME:$PATH"
125
72
pnpm config set store-dir /mnt/server/.pnpm-store
126
73
127
- echo "Cloning from: ${GITHUB_USER}/${REPOSITORY} (branch: ${BRANCH})"
74
+ # Ensure deployment directory exists
75
+ if [ ! -d "$DEPLOY_DIR" ]; then
76
+ mkdir -p "$DEPLOY_DIR"
77
+ fi
78
+
79
+ # Download release tarball and checksum file
80
+ cd /tmp
128
81
129
- # Clone or update repository
130
- if [ -d "$DEPLOY_DIR/.git" ]; then
131
- cd "$DEPLOY_DIR"
132
- git fetch origin
133
- git reset --hard "origin/$BRANCH"
82
+ # Construct the base release URL with token if provided
83
+ if [ -z "$TOKEN" ]; then
84
+ # Public repository
85
+ BASE_URL="https://github.com/${GITHUB_USER}/${REPOSITORY}/releases/download/${TAG}"
86
+ RELEASE_URL="${BASE_URL}/bot.tar.gz"
87
+ CHECKSUM_URL="${BASE_URL}/checksum.txt"
134
88
else
135
- if [ -d "$DEPLOY_DIR" ]; then
136
- if [ "$(ls -A "$DEPLOY_DIR")" ]; then
137
- echo "WARNING: Directory $DEPLOY_DIR is not empty"
138
- if [ "$WIPE" = "1" ]; then
139
- echo "Wiping directory..."
140
- rm -rf "$DEPLOY_DIR"
141
- mkdir -p "$DEPLOY_DIR"
142
- fi
143
- fi
144
- else
145
- mkdir -p "$DEPLOY_DIR"
146
- fi
147
-
148
- cd /tmp
149
- git clone -b "$BRANCH" "$SOURCE" "$DEPLOY_DIR"
150
- cd "$DEPLOY_DIR"
89
+ # Private repository with token
90
+ BASE_URL="https://${TOKEN}@github.com/${GITHUB_USER}/${REPOSITORY}/releases/download/${TAG}"
91
+ RELEASE_URL="${BASE_URL}/bot.tar.gz"
92
+ CHECKSUM_URL="${BASE_URL}/checksum.txt"
93
+ fi
94
+
95
+ echo "Downloading from: ${GITHUB_USER}/${REPOSITORY} (tag: ${TAG})"
96
+
97
+ # Download checksum file
98
+ echo "Downloading checksum file..."
99
+ wget -q --show-progress --header="Authorization: token ${TOKEN}" "$CHECKSUM_URL" -O checksum.txt
100
+ if [ $? -ne 0 ]; then
101
+ echo "Failed to download checksum file. Aborting installation."
102
+ exit 1
103
+ fi
104
+
105
+ # Download tarball
106
+ echo "Downloading release tarball..."
107
+ wget -q --show-progress --header="Authorization: token ${TOKEN}" "$RELEASE_URL" -O bot.tar.gz
108
+ if [ $? -ne 0 ]; then
109
+ echo "Failed to download release tarball. Aborting installation."
110
+ exit 1
151
111
fi
152
112
153
- # Setup environment
113
+ # Verify checksum
114
+ echo "Verifying file integrity..."
115
+ COMPUTED_CHECKSUM=$(sha256sum bot.tar.gz | awk '{print $1}')
116
+ EXPECTED_CHECKSUM=$(cat checksum.txt | awk '{print $1}')
117
+
118
+ if [ "$COMPUTED_CHECKSUM" != "$EXPECTED_CHECKSUM" ]; then
119
+ echo "Checksum verification failed!"
120
+ echo "Expected: $EXPECTED_CHECKSUM"
121
+ echo "Got: $COMPUTED_CHECKSUM"
122
+ echo "The downloaded file may be corrupted or tampered with. Aborting installation."
123
+ rm bot.tar.gz checksum.txt
124
+ exit 1
125
+ fi
126
+
127
+ echo "Checksum verification successful!"
128
+
129
+ # Extract to server directory
130
+ echo "Extracting files..."
131
+ tar -xzf bot.tar.gz -C "$DEPLOY_DIR"
132
+ rm bot.tar.gz checksum.txt
133
+
134
+ # Setup environment file
154
135
if [ ! -f "$DEPLOY_DIR/.env" ]; then
155
136
if [ -f "$DEPLOY_DIR/.env.example" ]; then
156
137
cp "$DEPLOY_DIR/.env.example" "$DEPLOY_DIR/.env"
@@ -165,18 +146,5 @@ install:
165
146
fi
166
147
fi
167
148
168
- # Install dependencies
169
- cd "$DEPLOY_DIR"
170
- pnpm install
171
-
172
- # Build the application
173
- if [ -f "$DEPLOY_DIR/build.sh" ]; then
174
- chmod +x "$DEPLOY_DIR/build.sh"
175
- ./build.sh
176
- else
177
- pnpm build
178
- fi
179
-
180
- echo "Installation complete."
181
- echo "Project has been installed from ${GITHUB_USER}/${REPOSITORY}."
149
+ echo "Release has been installed from ${GITHUB_USER}/${REPOSITORY} (tag: ${TAG})."
182
150
echo "Server will start on port {{server.build.default.port}} as configured in .env"
0 commit comments