Merge pull request 'fixed both script changed pip env to uv' (#10) from profilarr-script into dev
Reviewed-on: #10
This commit is contained in:
121
ct/profilarr.sh
121
ct/profilarr.sh
@ -30,59 +30,78 @@ function update_script() {
|
|||||||
msg_error "No ${APP} Installation Found!"
|
msg_error "No ${APP} Installation Found!"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
setup_uv
|
||||||
# Crawling the new version and checking whether an update is required
|
# Crawling the new version and checking whether an update is required
|
||||||
RELEASE=$(curl -fsSL https://api.github.com/repos/Dictionarry-Hub/profilarr/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4)}')
|
RELEASE=$(curl -fsSL https://api.github.com/repos/Dictionarry-Hub/profilarr/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')
|
||||||
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
|
if [[ -f /opt/${APP}_version.txt ]] && [[ "${RELEASE}" == "$(cat /opt/${APP}_version.txt)" ]]; then
|
||||||
# Stopping Services
|
msg_ok "No update required. ${APP} is already at ${RELEASE}"
|
||||||
msg_info "Stopping $APP"
|
exit
|
||||||
systemctl stop profilarr
|
|
||||||
msg_ok "Stopped $APP"
|
|
||||||
|
|
||||||
# Creating Backup
|
|
||||||
msg_info "Creating Backup"
|
|
||||||
tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" /opt/${APP} /opt/${APP}_config
|
|
||||||
msg_ok "Backup Created"
|
|
||||||
|
|
||||||
# Execute Update
|
|
||||||
msg_info "Updating $APP to v${RELEASE}"
|
|
||||||
temp_file=$(mktemp)
|
|
||||||
curl -fsSL -o "$temp_file" "https://github.com/Dictionarry-Hub/profilarr/archive/refs/tags/v${RELEASE}.zip"
|
|
||||||
cd /tmp
|
|
||||||
unzip -q "$temp_file"
|
|
||||||
rm -rf /opt/${APP}/backend /opt/${APP}/frontend
|
|
||||||
mv "profilarr-${RELEASE}/backend" /opt/${APP}/
|
|
||||||
mv "profilarr-${RELEASE}/frontend" /opt/${APP}/
|
|
||||||
|
|
||||||
# Update Python dependencies
|
|
||||||
cd /opt/${APP}/backend
|
|
||||||
/opt/${APP}/venv/bin/pip install -r requirements.txt
|
|
||||||
|
|
||||||
# Build frontend
|
|
||||||
cd /opt/${APP}/frontend
|
|
||||||
npm install
|
|
||||||
npm run build
|
|
||||||
cp -r dist/* /opt/${APP}/backend/app/static/
|
|
||||||
|
|
||||||
msg_ok "Updated $APP to v${RELEASE}"
|
|
||||||
|
|
||||||
# Starting Services
|
|
||||||
msg_info "Starting $APP"
|
|
||||||
systemctl start profilarr
|
|
||||||
msg_ok "Started $APP"
|
|
||||||
|
|
||||||
# Cleaning up
|
|
||||||
msg_info "Cleaning Up"
|
|
||||||
rm -f "$temp_file"
|
|
||||||
rm -rf "/tmp/profilarr-${RELEASE}"
|
|
||||||
msg_ok "Cleanup Completed"
|
|
||||||
|
|
||||||
# Last Action
|
|
||||||
echo "${RELEASE}" >/opt/${APP}_version.txt
|
|
||||||
msg_ok "Update Successful"
|
|
||||||
else
|
|
||||||
msg_ok "No update required. ${APP} is already at v${RELEASE}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Stopping Services
|
||||||
|
msg_info "Stopping $APP"
|
||||||
|
systemctl stop ${APP}
|
||||||
|
msg_ok "Stopped $APP"
|
||||||
|
|
||||||
|
# Creating Backup
|
||||||
|
msg_info "Creating Backup"
|
||||||
|
if ls /opt/"${APP}"_backup_*.tar.gz &>/dev/null; then
|
||||||
|
rm -f /opt/"${APP}"_backup_*.tar.gz
|
||||||
|
msg_info "Removed previous backup"
|
||||||
|
fi
|
||||||
|
tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" /opt/${APP} /opt/${APP}_config
|
||||||
|
msg_ok "Backup Created"
|
||||||
|
|
||||||
|
# Execute Update
|
||||||
|
msg_info "Updating $APP to v${RELEASE}"
|
||||||
|
temp_file=$(mktemp)
|
||||||
|
curl -fsSL -o "$temp_file" "https://github.com/Dictionarry-Hub/profilarr/archive/refs/tags/${RELEASE}.zip"
|
||||||
|
unzip -q -o "$temp_file" -d /tmp
|
||||||
|
rm -rf /opt/${APP}/backend /opt/${APP}/frontend
|
||||||
|
mv "/tmp/profilarr-${RELEASE}/backend" /opt/${APP}/
|
||||||
|
mv "/tmp/profilarr-${RELEASE}/frontend" /opt/${APP}/
|
||||||
|
|
||||||
|
# Update Python dependencies
|
||||||
|
msg_info "Updating Python dependencies"
|
||||||
|
cd /opt/${APP}/backend || exit
|
||||||
|
if [[ -f "/opt/${APP}/.requirements_checksum" ]]; then
|
||||||
|
CURRENT_CHECKSUM=$(md5sum requirements.txt | awk '{print $1}')
|
||||||
|
STORED_CHECKSUM=$(cat /opt/${APP}/.requirements_checksum)
|
||||||
|
if [[ "$CURRENT_CHECKSUM" != "$STORED_CHECKSUM" ]]; then
|
||||||
|
msg_info "Requirements have changed. Performing full upgrade."
|
||||||
|
$STD uv pip install -r requirements.txt --python /opt/${APP}/venv/bin/python
|
||||||
|
else
|
||||||
|
msg_info "Requirements unchanged. Verifying installation."
|
||||||
|
$STD uv pip install -r requirements.txt --python /opt/${APP}/venv/bin/python
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
$STD uv pip install -r requirements.txt --python /opt/${APP}/venv/bin/python
|
||||||
|
fi
|
||||||
|
md5sum requirements.txt | awk '{print $1}' >/opt/${APP}/.requirements_checksum
|
||||||
|
msg_ok "Updated Python dependencies"
|
||||||
|
|
||||||
|
# Build frontend
|
||||||
|
msg_info "Building Frontend"
|
||||||
|
cd /opt/${APP}/frontend || exit
|
||||||
|
npm install
|
||||||
|
npm run build
|
||||||
|
cp -r dist/* /opt/${APP}/backend/app/static/
|
||||||
|
msg_ok "Built Frontend"
|
||||||
|
|
||||||
|
# Starting Services
|
||||||
|
msg_info "Starting $APP"
|
||||||
|
systemctl start ${APP}
|
||||||
|
msg_ok "Started $APP"
|
||||||
|
|
||||||
|
# Cleaning up
|
||||||
|
msg_info "Cleaning Up"
|
||||||
|
rm -f "$temp_file"
|
||||||
|
rm -rf "/tmp/profilarr-${RELEASE}"
|
||||||
|
msg_ok "Cleanup Completed"
|
||||||
|
|
||||||
|
# Last Action
|
||||||
|
echo "${RELEASE}" >/opt/${APP}_version.txt
|
||||||
|
msg_ok "Updated $APP to v${RELEASE}"
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,6 @@
|
|||||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||||
# Source: https://github.com/Dictionarry-Hub/profilarr
|
# Source: https://github.com/Dictionarry-Hub/profilarr
|
||||||
|
|
||||||
# Import Functions and Setup
|
|
||||||
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
|
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
|
||||||
color
|
color
|
||||||
verb_ip6
|
verb_ip6
|
||||||
@ -18,48 +17,39 @@ APPLICATION="profilarr"
|
|||||||
|
|
||||||
msg_info "Installing Dependencies"
|
msg_info "Installing Dependencies"
|
||||||
$STD apt-get install -y \
|
$STD apt-get install -y \
|
||||||
curl \
|
|
||||||
wget \
|
|
||||||
git \
|
|
||||||
unzip \
|
unzip \
|
||||||
build-essential \
|
build-essential
|
||||||
python3 \
|
|
||||||
python3-pip \
|
|
||||||
python3-venv \
|
|
||||||
ca-certificates \
|
|
||||||
gnupg
|
|
||||||
msg_ok "Installed Dependencies"
|
msg_ok "Installed Dependencies"
|
||||||
|
|
||||||
|
msg_info "Installing Python"
|
||||||
|
$STD apt-get install -y \
|
||||||
|
python3 \
|
||||||
|
python3-venv
|
||||||
|
msg_ok "Installed Python"
|
||||||
|
|
||||||
|
msg_info "Setup uv"
|
||||||
|
setup_uv
|
||||||
|
msg_ok "Setup uv"
|
||||||
|
|
||||||
msg_info "Installing Node.js"
|
msg_info "Installing Node.js"
|
||||||
$STD mkdir -p /etc/apt/keyrings
|
NODE_VERSION="20" install_node_and_modules
|
||||||
$STD curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
|
|
||||||
$STD echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
|
|
||||||
$STD apt-get update
|
|
||||||
$STD apt-get install -y nodejs
|
|
||||||
msg_ok "Installed Node.js"
|
msg_ok "Installed Node.js"
|
||||||
|
|
||||||
msg_info "Setup ${APPLICATION}"
|
msg_info "Setup ${APPLICATION}"
|
||||||
RELEASE=$(curl -fsSL https://api.github.com/repos/Dictionarry-Hub/profilarr/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4)}')
|
RELEASE=$(curl -fsSL https://api.github.com/repos/Dictionarry-Hub/profilarr/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')
|
||||||
temp_file=$(mktemp)
|
temp_file=$(mktemp)
|
||||||
$STD curl -fsSL -o "$temp_file" "https://github.com/Dictionarry-Hub/profilarr/archive/refs/tags/v${RELEASE}.zip"
|
$STD curl -fsSL -o "$temp_file" "https://github.com/Dictionarry-Hub/profilarr/archive/refs/tags/${RELEASE}.zip"
|
||||||
cd /tmp
|
$STD unzip -q "$temp_file" -d /tmp
|
||||||
$STD unzip -q "$temp_file"
|
|
||||||
$STD mkdir -p /opt/${APPLICATION}
|
$STD mkdir -p /opt/${APPLICATION}
|
||||||
$STD mkdir -p /opt/${APPLICATION}_config
|
$STD mkdir -p /opt/${APPLICATION}_config
|
||||||
$STD mv "profilarr-${RELEASE}/backend" /opt/${APPLICATION}/
|
$STD mv "/tmp/profilarr-${RELEASE}/backend" /opt/${APPLICATION}/
|
||||||
$STD mv "profilarr-${RELEASE}/frontend" /opt/${APPLICATION}/
|
$STD mv "/tmp/profilarr-${RELEASE}/frontend" /opt/${APPLICATION}/
|
||||||
$STD chown -R root:root /opt/${APPLICATION}
|
|
||||||
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
|
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
|
||||||
|
$STD uv venv /opt/${APPLICATION}/venv
|
||||||
|
$STD uv pip install --python /opt/${APPLICATION}/venv/bin/python -r /opt/${APPLICATION}/backend/requirements.txt
|
||||||
|
$STD uv pip install --python /opt/${APPLICATION}/venv/bin/python gunicorn
|
||||||
msg_ok "Setup ${APPLICATION}"
|
msg_ok "Setup ${APPLICATION}"
|
||||||
|
|
||||||
msg_info "Setting up Python Virtual Environment"
|
|
||||||
$STD python3 -m venv /opt/${APPLICATION}/venv
|
|
||||||
$STD /opt/${APPLICATION}/venv/bin/pip install --upgrade pip
|
|
||||||
cd /opt/${APPLICATION}/backend
|
|
||||||
$STD /opt/${APPLICATION}/venv/bin/pip install -r requirements.txt
|
|
||||||
$STD /opt/${APPLICATION}/venv/bin/pip install gunicorn
|
|
||||||
msg_ok "Setup Python Environment"
|
|
||||||
|
|
||||||
msg_info "Building Frontend"
|
msg_info "Building Frontend"
|
||||||
cd /opt/${APPLICATION}/frontend
|
cd /opt/${APPLICATION}/frontend
|
||||||
$STD npm install
|
$STD npm install
|
||||||
@ -73,7 +63,6 @@ cat <<EOF >/etc/systemd/system/${APPLICATION}.service
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Profilarr Profile Manager
|
Description=Profilarr Profile Manager
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
User=root
|
User=root
|
||||||
@ -83,14 +72,12 @@ Environment=CONFIG_PATH=/opt/${APPLICATION}_config
|
|||||||
ExecStart=/opt/${APPLICATION}/venv/bin/gunicorn --bind 0.0.0.0:6868 --workers 2 --timeout 120 app.main:create_app()
|
ExecStart=/opt/${APPLICATION}/venv/bin/gunicorn --bind 0.0.0.0:6868 --workers 2 --timeout 120 app.main:create_app()
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=10
|
RestartSec=10
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
$STD systemctl daemon-reload
|
$STD systemctl daemon-reload
|
||||||
$STD systemctl enable ${APPLICATION}.service
|
systemctl enable -q --now ${APPLICATION}
|
||||||
$STD systemctl start ${APPLICATION}.service
|
|
||||||
msg_ok "Created Service"
|
msg_ok "Created Service"
|
||||||
|
|
||||||
motd_ssh
|
motd_ssh
|
||||||
|
|||||||
Reference in New Issue
Block a user