Skip to content

Commit 077c866

Browse files
authored
Refactor (#8828)
1 parent 95c17ad commit 077c866

File tree

2 files changed

+20
-27
lines changed

2 files changed

+20
-27
lines changed

ct/pangolin.sh

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,42 +32,38 @@ function update_script() {
3232
if check_for_gh_release "pangolin" "fosrl/pangolin"; then
3333
msg_info "Stopping Service"
3434
systemctl stop pangolin
35+
systemctl stop gerbil
3536
msg_info "Service stopped"
3637

3738
msg_info "Creating backup"
3839
tar -czf /opt/pangolin_config_backup.tar.gz -C /opt/pangolin config
3940
msg_ok "Created backup"
4041

41-
fetch_and_deploy_gh_release "pangolin" "fosrl/pangolin" "tarball"
42-
fetch_and_deploy_gh_release "gerbil" "fosrl/gerbil" "singlefile" "latest" "/usr/bin" "gerbil_linux_amd64"
42+
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "pangolin" "fosrl/pangolin" "tarball"
43+
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "gerbil" "fosrl/gerbil" "singlefile" "latest" "/usr/bin" "gerbil_linux_amd64"
4344

4445
msg_info "Updating Pangolin"
45-
export BUILD=oss
46-
export DATABASE=sqlite
4746
cd /opt/pangolin
4847
$STD npm ci
49-
echo "export * from \"./$DATABASE\";" > server/db/index.ts
50-
echo "export const build = \"$BUILD\" as any;" > server/build.ts
51-
cp tsconfig.oss.json tsconfig.json
52-
$STD npm run next:build
53-
$STD node esbuild.mjs -e server/index.ts -o dist/server.mjs -b $BUILD
54-
$STD node esbuild.mjs -e server/setup/migrationsSqlite.ts -o dist/migrations.mjs
48+
$STD npm run set:sqlite
49+
$STD npm run set:oss
50+
rm -rf server/private
51+
$STD npm run build:sqlite
5552
$STD npm run build:cli
5653
cp -R .next/standalone ./
57-
58-
cat <<EOF >/usr/local/bin/pangctl
59-
#!/bin/sh
60-
cd /opt/pangolin
61-
./dist/cli.mjs "$@"
62-
EOF
63-
chmod +x /usr/local/bin/pangctl ./dist/cli.mjs
54+
chmod +x ./dist/cli.mjs
6455
cp server/db/names.json ./dist/names.json
6556
msg_ok "Updated Pangolin"
6657

6758
msg_info "Restoring config"
6859
tar -xzf /opt/pangolin_config_backup.tar.gz -C /opt/pangolin --overwrite
6960
rm -f /opt/pangolin_config_backup.tar.gz
7061
msg_ok "Restored config"
62+
63+
msg_info "Starting Services"
64+
systemctl start pangolin
65+
systemctl start gerbil
66+
msg_ok "Started Services"
7167
msg_ok "Updated successfully!"
7268
fi
7369
exit

install/pangolin-install.sh

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,12 @@ fetch_and_deploy_gh_release "gerbil" "fosrl/gerbil" "singlefile" "latest" "/usr/
2626
msg_info "Setup Pangolin"
2727
IP_ADDR=$(hostname -I | awk '{print $1}')
2828
SECRET_KEY=$(openssl rand -base64 48 | tr -dc 'A-Za-z0-9' | head -c 32)
29-
export BUILD=oss
30-
export DATABASE=sqlite
3129
cd /opt/pangolin
3230
$STD npm ci
33-
echo "export * from \"./$DATABASE\";" > server/db/index.ts
34-
echo "export const build = \"$BUILD\" as any;" > server/build.ts
35-
cp tsconfig.oss.json tsconfig.json
36-
mkdir -p dist
37-
$STD npm run next:build
38-
$STD node esbuild.mjs -e server/index.ts -o dist/server.mjs -b $BUILD
39-
$STD node esbuild.mjs -e server/setup/migrationsSqlite.ts -o dist/migrations.mjs
31+
$STD npm run set:sqlite
32+
$STD npm run set:oss
33+
rm -rf server/private
34+
$STD npm run build:sqlite
4035
$STD npm run build:cli
4136
cp -R .next/standalone ./
4237

@@ -98,8 +93,10 @@ After=network.target
9893
[Service]
9994
Type=simple
10095
User=root
96+
Environment=NODE_ENV=production
97+
Environment=ENVIRONMENT=prod
10198
WorkingDirectory=/opt/pangolin
102-
ExecStart=/usr/bin/npm start
99+
ExecStart=/usr/bin/node --enable-source-maps dist/server.mjs
103100
Restart=always
104101
RestartSec=10
105102

0 commit comments

Comments
 (0)