This commit is contained in:
CanbiZ 2025-04-14 15:06:09 +02:00
parent f18e8a6442
commit deb8b15697
2 changed files with 86 additions and 87 deletions

View File

@ -20,81 +20,80 @@ color
catch_errors
function update_script() {
header_info
check_container_storage
check_container_resources
header_info
check_container_storage
check_container_resources
if [[ ! -f /etc/systemd/system/Reactive-Resume.service ]]; then
msg_error "No ${APP} Installation Found!"
if [[ ! -f /etc/systemd/system/Reactive-Resume.service ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
RELEASE=$(curl -s https://api.github.com/repos/AmruthPillai/Reactive-Resume/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
msg_info "Stopping services"
systemctl stop Reactive-Resume
msg_ok "Stopped services"
msg_info "Updating $APP to v${RELEASE}"
cp /opt/${APP}/.env /opt/rxresume.env
res_tmp=$(mktemp)
rm -rf /opt/${APP}
curl -fsSL "https://github.com/AmruthPillai/Reactive-Resume/archive/refs/tags/v${RELEASE}.zip" -O $res_tmp
unzip -q $res_tmp
mv ${APP}-${RELEASE}/ /opt/${APP}
cd /opt/${APP}
export PUPPETEER_SKIP_DOWNLOAD="true"
export NEXT_TELEMETRY_DISABLED=1
export CI="true"
export NODE_ENV="production"
$STD pnpm install --frozen-lockfile
$STD pnpm run build
$STD pnpm run prisma:generate
mv /opt/rxresume.env /opt/${APP}/.env
msg_ok "Updated $APP to v${RELEASE}"
msg_info "Updating Minio"
systemctl stop minio
cd /tmp
curl -fsSL https://dl.min.io/server/minio/release/linux-amd64/minio.deb -o minio.deb
$STD dpkg -i minio.deb
msg_ok "Updated Minio"
msg_info "Updating Browserless (Patience)"
systemctl stop browserless
cp /opt/browserless/.env /opt/browserless.env
rm -rf browserless
brwsr_tmp=$(mktemp)
TAG=$(curl -fsSL https://api.github.com/repos/browserless/browserless/tags?per_page=1 | grep "name" | awk '{print substr($2, 3, length($2)-4) }')
curl -fsSL https://github.com/browserless/browserless/archive/refs/tags/v${TAG}.zip -O $brwsr_tmp
unzip -q $brwsr_tmp
mv browserless-${TAG}/ /opt/browserless
cd /opt/browserless
$STD npm install
rm -rf src/routes/{chrome,edge,firefox,webkit}
$STD node_modules/playwright-core/cli.js install --with-deps chromium
$STD npm run build
$STD npm run build:function
$STD npm prune production
mv /opt/browserless.env /opt/browserless/.env
msg_ok "Updated Browserless"
msg_info "Restarting services"
systemctl start minio Reactive-Resume browserless
msg_ok "Restarted services"
msg_info "Cleaning Up"
rm -f /tmp/minio.deb
rm -f $brwsr_tmp
rm -f $res_tmp
msg_ok "Cleanup Completed"
echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Update Successful"
else
msg_ok "No update required. ${APP} is already at v${RELEASE}"
fi
exit
fi
RELEASE=$(curl -s https://api.github.com/repos/AmruthPillai/Reactive-Resume/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
msg_info "Stopping services"
systemctl stop Reactive-Resume
msg_ok "Stopped services"
msg_info "Updating $APP to v${RELEASE}"
cp /opt/${APP}/.env /opt/rxresume.env
res_tmp=$(mktemp)
rm -rf /opt/${APP}
wget -q "https://github.com/AmruthPillai/Reactive-Resume/archive/refs/tags/v${RELEASE}.zip" -O $res_tmp
unzip -q $res_tmp
mv ${APP}-${RELEASE}/ /opt/${APP}
cd /opt/${APP}
export PUPPETEER_SKIP_DOWNLOAD="true"
export NEXT_TELEMETRY_DISABLED=1
export CI="true"
export NODE_ENV="production"
$STD pnpm install --frozen-lockfile
$STD pnpm run build
$STD pnpm run prisma:generate
mv /opt/rxresume.env /opt/${APP}/.env
msg_ok "Updated $APP to v${RELEASE}"
msg_info "Updating Minio"
systemctl stop minio
cd /tmp
wget -q https://dl.min.io/server/minio/release/linux-amd64/minio.deb
$STD dpkg -i minio.deb
msg_ok "Updated Minio"
msg_info "Updating Browserless (Patience)"
systemctl stop browserless
cp /opt/browserless/.env /opt/browserless.env
rm -rf browserless
brwsr_tmp=$(mktemp)
TAG=$(curl -s https://api.github.com/repos/browserless/browserless/tags?per_page=1 | grep "name" | awk '{print substr($2, 3, length($2)-4) }')
wget -q https://github.com/browserless/browserless/archive/refs/tags/v${TAG}.zip -O $brwsr_tmp
unzip -q $brwsr_tmp
mv browserless-${TAG}/ /opt/browserless
cd /opt/browserless
$STD npm install
rm -rf src/routes/{chrome,edge,firefox,webkit}
$STD node_modules/playwright-core/cli.js install --with-deps chromium
$STD npm run build
$STD npm run build:function
$STD npm prune production
mv /opt/browserless.env /opt/browserless/.env
msg_ok "Updated Browserless"
msg_info "Restarting services"
systemctl start minio Reactive-Resume browserless
msg_ok "Restarted services"
msg_info "Cleaning Up"
rm -f /tmp/minio.deb
rm -f $brwsr_tmp
rm -f $res_tmp
msg_ok "Cleanup Completed"
echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Update Successful"
else
msg_ok "No update required. ${APP} is already at v${RELEASE}"
fi
exit
}
start

View File

@ -15,9 +15,9 @@ update_os
msg_info "Installing Dependencies"
$STD apt-get install -y \
gnupg \
unzip \
postgresql-common
gnupg \
unzip \
postgresql-common
msg_ok "Installed Dependencies"
msg_info "Installing Additional Dependencies"
@ -27,7 +27,7 @@ echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.co
echo "YES" | /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh &>/dev/null
$STD apt-get install -y postgresql-16 nodejs
cd /tmp
wget -q https://dl.min.io/server/minio/release/linux-amd64/minio.deb
curl -fsSL https://dl.min.io/server/minio/release/linux-amd64/minio.deb -o minio.deb
$STD dpkg -i minio.deb
msg_info "Setting up Database"
@ -46,9 +46,9 @@ ACCESS_TOKEN=$(openssl rand -base64 48)
REFRESH_TOKEN=$(openssl rand -base64 48)
CHROME_TOKEN=$(openssl rand -hex 32)
LOCAL_IP=$(hostname -I | awk '{print $1}')
TAG=$(curl -s https://api.github.com/repos/browserless/browserless/tags?per_page=1 | grep "name" | awk '{print substr($2, 3, length($2)-4) }')
RELEASE=$(curl -s https://api.github.com/repos/AmruthPillai/Reactive-Resume/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
wget -q "https://github.com/AmruthPillai/Reactive-Resume/archive/refs/tags/v${RELEASE}.zip"
TAG=$(curl -fsSL https://api.github.com/repos/browserless/browserless/tags?per_page=1 | grep "name" | awk '{print substr($2, 3, length($2)-4) }')
RELEASE=$(curl -fsSL https://api.github.com/repos/AmruthPillai/Reactive-Resume/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
curl -fsSL "https://github.com/AmruthPillai/Reactive-Resume/archive/refs/tags/v${RELEASE}.zip" -o v${RELEASE}.zip
unzip -q v${RELEASE}.zip
mv ${APPLICATION}-${RELEASE}/ /opt/${APPLICATION}
cd /opt/${APPLICATION}
@ -65,7 +65,7 @@ msg_ok "Installed ${APPLICATION}"
msg_info "Installing Browserless (Patience)"
cd /tmp
wget -q https://github.com/browserless/browserless/archive/refs/tags/v${TAG}.zip
curl -fsSL https://github.com/browserless/browserless/archive/refs/tags/v${TAG}.zip -o v${TAG}.zip
unzip -q v${TAG}.zip
mv browserless-${TAG} /opt/browserless
cd /opt/browserless
@ -126,11 +126,11 @@ TOKEN=${CHROME_TOKEN}
EOF
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
{
echo "${APPLICATION} Credentials"
echo "Database User: $DB_USER"
echo "Database Password: $DB_PASS"
echo "Database Name: $DB_NAME"
echo "Minio Root Password: ${MINIO_PASS}"
echo "${APPLICATION} Credentials"
echo "Database User: $DB_USER"
echo "Database Password: $DB_PASS"
echo "Database Name: $DB_NAME"
echo "Minio Root Password: ${MINIO_PASS}"
} >>~/${APPLICATION}.creds
msg_ok "Configured applications"