@@ -29,59 +29,53 @@ function update_script() {
2929 exit
3030 fi
3131
32- msg_info " Stopping ${APP} Service"
33- systemctl stop metube
34- msg_ok " Stopped ${APP} Service"
35-
36- msg_info " Backing up Old Installation"
37- if [[ -d /opt/metube_bak ]]; then
38- rm -rf /opt/metube_bak
32+ if [[ $( echo " :$PATH :" ! = * " :/usr/local/bin:" * ) ]]; then
33+ echo ' export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
34+ source ~ /.bashrc
35+ if ! command -v deno & > /dev/null; then
36+ export DENO_INSTALL=" /usr/local"
37+ curl -fsSL https://deno.land/install.sh | $STD sh -s -- -y
38+ else
39+ $STD deno upgrade
40+ fi
3941 fi
40- mv /opt/metube /opt/metube_bak
41- msg_ok " Backup created"
42-
43- msg_info " Cloning Latest ${APP} Release"
44- $STD git clone https://github.com/alexta69/metube /opt/metube
45- msg_ok " Cloned ${APP} "
46-
47- msg_info " Building Frontend"
48- cd /opt/metube/ui
49- $STD npm install
50- $STD node_modules/.bin/ng build
51- msg_ok " Built Frontend"
52-
53- PYTHON_VERSION=" 3.13" setup_uv
54-
55- msg_info " Setting up Python Environment (uv)"
56- $STD uv venv /opt/metube/.venv
57- $STD /opt/metube/.venv/bin/python -m ensurepip --upgrade
58- $STD /opt/metube/.venv/bin/python -m pip install --upgrade pip
59- $STD /opt/metube/.venv/bin/python -m pip install pipenv
60- msg_ok " Python Environment Ready"
61-
62- msg_info " Installing Backend Requirements"
63- cd /opt/metube
64- $STD /opt/metube/.venv/bin/pipenv install
65- msg_ok " Installed Backend"
66-
67- msg_info " Restoring Environment File"
68- if [[ -f /opt/metube_bak/.env ]]; then
69- cp /opt/metube_bak/.env /opt/metube/.env
70- fi
71- msg_ok " Restored .env"
7242
73- if [[ ! -d /opt/metube/.venv ]]; then
74- msg_info " Migrating to uv-based environment"
43+ if check_for_gh_release " metube" " alexta69/metube" ; then
44+ msg_info " Stopping ${APP} Service"
45+ systemctl stop metube
46+ msg_ok " Stopped ${APP} Service"
47+
48+ msg_info " Backing up Old Installation"
49+ if [[ -d /opt/metube_bak ]]; then
50+ rm -rf /opt/metube_bak
51+ fi
52+ mv /opt/metube /opt/metube_bak
53+ msg_ok " Backup created"
54+
55+ fetch_and_deploy_gh_release " metube" " alexta69/metube" " tarball" " latest"
56+
57+ msg_info " Building Frontend"
58+ cd /opt/metube/ui
59+ $STD npm install
60+ $STD node_modules/.bin/ng build
61+ msg_ok " Built Frontend"
62+
7563 PYTHON_VERSION=" 3.13" setup_uv
76- $STD uv venv /opt/metube/.venv
77- $STD /opt/metube/.venv/bin/python -m ensurepip --upgrade
78- $STD /opt/metube/.venv/bin/python -m pip install --upgrade pip
79- $STD /opt/metube/.venv/bin/python -m pip install pipenv
80- $STD /opt/metube/.venv/bin/pipenv install
81- $STD /opt/metube/.venv/bin/pipenv update yt-dlp
82-
83- msg_info " Patching systemd Service"
84- cat << EOF >/etc/systemd/system/metube.service
64+
65+ msg_info " Installing Backend Requirements"
66+ cd /opt/metube
67+ $STD uv sync --frozen --no-dev
68+ msg_ok " Installed Backend"
69+
70+ msg_info " Restoring Environment File"
71+ if [[ -f /opt/metube_bak/.env ]]; then
72+ cp /opt/metube_bak/.env /opt/metube/.env
73+ fi
74+ msg_ok " Restored .env"
75+
76+ if grep -q ' pipenv' /etc/systemd/system/metube.service; then
77+ msg_info " Patching systemd Service"
78+ cat << EOF >/etc/systemd/system/metube.service
8579[Unit]
8680Description=Metube - YouTube Downloader
8781After=network.target
@@ -90,30 +84,31 @@ After=network.target
9084Type=simple
9185WorkingDirectory=/opt/metube
9286EnvironmentFile=/opt/metube/.env
93- ExecStart=/opt/metube/.venv/bin/pipenv run python3 app/main.py
87+ ExecStart=/opt/metube/.venv/bin/python3 app/main.py
9488Restart=always
9589User=root
9690
9791[Install]
9892WantedBy=multi-user.target
9993EOF
100- msg_ok " Patched systemd Service"
101- fi
102- $STD systemctl daemon-reload
103- msg_ok " Service Updated"
94+ msg_ok " Patched systemd Service"
95+ fi
96+ $STD systemctl daemon-reload
97+ msg_ok " Service Updated"
10498
105- msg_info " Cleaning up"
106- rm -rf /opt/metube_bak
107- $STD apt-get -y autoremove
108- $STD apt-get -y autoclean
109- msg_ok " Cleaned Up"
99+ msg_info " Cleaning up"
100+ rm -rf /opt/metube_bak
101+ $STD apt-get -y autoremove
102+ $STD apt-get -y autoclean
103+ msg_ok " Cleaned Up"
110104
111- msg_info " Starting ${APP} Service"
112- systemctl enable -q --now metube
113- sleep 1
114- msg_ok " Started ${APP} Service"
105+ msg_info " Starting ${APP} Service"
106+ systemctl start metube
107+ sleep 1
108+ msg_ok " Started ${APP} Service"
115109
116- msg_ok " Updated Successfully!"
110+ msg_ok " Updated Successfully!"
111+ fi
117112}
118113
119114start
0 commit comments