Refactor (#6872)
This commit is contained in:
parent
ee74400626
commit
24f4d2f488
@ -27,22 +27,20 @@ function update_script() {
|
|||||||
msg_error "No ${APP} Installation Found!"
|
msg_error "No ${APP} Installation Found!"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
RELEASE=$(curl -fsSL https://api.github.com/repos/sbondCo/Watcharr/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
RELEASE=$(curl -fsSL https://api.github.com/repos/sbondCo/Watcharr/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
|
if [[ "${RELEASE}" != "$(cat ~/.watcharr)" ]] || [[ ! -f ~/.watcharr ]]; then
|
||||||
msg_info "Updating $APP"
|
msg_info "Updating $APP"
|
||||||
|
|
||||||
msg_info "Stopping $APP"
|
msg_info "Stopping $APP"
|
||||||
systemctl stop watcharr
|
systemctl stop watcharr
|
||||||
msg_ok "Stopped $APP"
|
msg_ok "Stopped $APP"
|
||||||
|
|
||||||
msg_info "Updating $APP to v${RELEASE}"
|
|
||||||
temp_file=$(mktemp)
|
|
||||||
temp_folder=$(mktemp -d)
|
|
||||||
curl -fsSL "https://github.com/sbondCo/Watcharr/archive/refs/tags/v${RELEASE}.tar.gz" -o ""$temp_file""
|
|
||||||
tar -xzf "$temp_file" -C "$temp_folder"
|
|
||||||
rm -f /opt/watcharr/server/watcharr
|
rm -f /opt/watcharr/server/watcharr
|
||||||
rm -rf /opt/watcharr/server/ui
|
rm -rf /opt/watcharr/server/ui
|
||||||
cp -rf ${temp_folder}/Watcharr-${RELEASE}/* /opt/watcharr
|
fetch_and_deploy_gh_release "watcharr" "sbondCo/Watcharr" "tarball"
|
||||||
|
|
||||||
|
msg_info "Updating $APP to v${RELEASE}"
|
||||||
cd /opt/watcharr
|
cd /opt/watcharr
|
||||||
export GOOS=linux
|
export GOOS=linux
|
||||||
$STD npm i
|
$STD npm i
|
||||||
@ -57,12 +55,6 @@ function update_script() {
|
|||||||
systemctl start watcharr
|
systemctl start watcharr
|
||||||
msg_ok "Started $APP"
|
msg_ok "Started $APP"
|
||||||
|
|
||||||
msg_info "Cleaning Up"
|
|
||||||
rm -f ${temp_file}
|
|
||||||
rm -rf ${temp_folder}
|
|
||||||
msg_ok "Cleanup Completed"
|
|
||||||
|
|
||||||
echo "${RELEASE}" >/opt/${APP}_version.txt
|
|
||||||
msg_ok "Update Successful"
|
msg_ok "Update Successful"
|
||||||
else
|
else
|
||||||
msg_ok "No update required. ${APP} is already at v${RELEASE}"
|
msg_ok "No update required. ${APP} is already at v${RELEASE}"
|
||||||
|
@ -14,19 +14,14 @@ network_check
|
|||||||
update_os
|
update_os
|
||||||
|
|
||||||
msg_info "Installing Dependencies"
|
msg_info "Installing Dependencies"
|
||||||
$STD apt-get install -y \
|
$STD apt-get install -y gcc
|
||||||
gcc
|
|
||||||
msg_ok "Installed Dependencies"
|
msg_ok "Installed Dependencies"
|
||||||
|
|
||||||
setup_go
|
setup_go
|
||||||
NODE_VERSION="22" setup_nodejs
|
NODE_VERSION="22" setup_nodejs
|
||||||
|
fetch_and_deploy_gh_release "watcharr" "sbondCo/Watcharr" "tarball"
|
||||||
|
|
||||||
msg_info "Setup Watcharr"
|
msg_info "Setup Watcharr"
|
||||||
temp_file=$(mktemp)
|
|
||||||
RELEASE=$(curl -fsSL https://api.github.com/repos/sbondCo/Watcharr/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
|
||||||
curl -fsSL "https://github.com/sbondCo/Watcharr/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
|
|
||||||
tar -xzf "$temp_file"
|
|
||||||
mv Watcharr-${RELEASE}/ /opt/watcharr
|
|
||||||
cd /opt/watcharr
|
cd /opt/watcharr
|
||||||
$STD npm i
|
$STD npm i
|
||||||
$STD npm run build
|
$STD npm run build
|
||||||
@ -35,14 +30,6 @@ cd server
|
|||||||
export CGO_ENABLED=1 GOOS=linux
|
export CGO_ENABLED=1 GOOS=linux
|
||||||
go mod download
|
go mod download
|
||||||
go build -o ./watcharr
|
go build -o ./watcharr
|
||||||
cat <<EOF >/opt/start.sh
|
|
||||||
#! /bin/bash
|
|
||||||
source ~/.bashrc
|
|
||||||
cd /opt/watcharr/server
|
|
||||||
./watcharr
|
|
||||||
EOF
|
|
||||||
chmod +x /opt/start.sh
|
|
||||||
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
|
|
||||||
msg_ok "Setup Watcharr"
|
msg_ok "Setup Watcharr"
|
||||||
|
|
||||||
msg_info "Creating Service"
|
msg_info "Creating Service"
|
||||||
@ -53,7 +40,7 @@ After=network.target
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
WorkingDirectory=/opt/watcharr/server
|
WorkingDirectory=/opt/watcharr/server
|
||||||
ExecStart=/opt/start.sh
|
ExecStart=/opt/watcharr/server/watcharr
|
||||||
Restart=always
|
Restart=always
|
||||||
User=root
|
User=root
|
||||||
|
|
||||||
@ -67,7 +54,6 @@ motd_ssh
|
|||||||
customize
|
customize
|
||||||
|
|
||||||
msg_info "Cleaning up"
|
msg_info "Cleaning up"
|
||||||
rm -f "$temp_file"
|
|
||||||
$STD apt-get -y autoremove
|
$STD apt-get -y autoremove
|
||||||
$STD apt-get -y autoclean
|
$STD apt-get -y autoclean
|
||||||
msg_ok "Cleaned"
|
msg_ok "Cleaned"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user