Compare commits

16 Commits

Author SHA1 Message Date
9df8b9cd2e Merge pull request 'fix: update repository URLs from Dictionarry-Hub to BiluliB' (#22) from profilarr-script into dev
Reviewed-on: #22
2025-07-22 16:16:33 +02:00
a1c4e94cb5 fix: update repository URLs from Dictionarry-Hub to BiluliB 2025-07-22 14:16:14 +00:00
8160861e6b Merge pull request 'fix: resolve update script repository inconsistency and missing directory' (#21) from profilarr-script into dev
Reviewed-on: #21
2025-07-22 15:35:51 +02:00
edc54b2e85 fix: resolve update script repository inconsistency and missing directory 2025-07-22 13:35:39 +00:00
5278685dff Merge pull request 'changed update url' (#20) from profilarr-script into dev
Reviewed-on: #20
2025-07-22 15:33:26 +02:00
4eb3a9c2c3 changed update url 2025-07-22 13:33:11 +00:00
3a2d253bcc Merge pull request 'remove v from release variable' (#19) from profilarr-script into dev
Reviewed-on: #19
2025-07-22 15:31:29 +02:00
4d37f159ad remove v from release variable 2025-07-22 13:30:46 +00:00
2f835e0f74 Merge pull request 'change version to own github version' (#18) from profilarr-script into dev
Reviewed-on: #18
2025-07-22 15:26:39 +02:00
620dbd7bcc change version to own github version 2025-07-22 13:26:23 +00:00
b2f703d985 Merge pull request 'chanege execstart line' (#17) from profilarr-script into dev
Reviewed-on: #17
2025-07-21 16:11:20 +02:00
38c3c5b0c7 chanege execstart line 2025-07-21 16:11:06 +02:00
8c90128f9a Merge pull request 'add git as dependency' (#16) from profilarr-script into dev
Reviewed-on: #16
2025-07-21 15:23:57 +02:00
a2b9b1482b add git as dependency 2025-07-21 15:23:45 +02:00
9bb805cb99 Merge pull request 'fix service code' (#15) from profilarr-script into dev
Reviewed-on: #15
2025-07-21 15:19:24 +02:00
d65523e429 fix service code 2025-07-21 15:19:09 +02:00
2 changed files with 131 additions and 9 deletions

View File

@ -32,7 +32,7 @@ function update_script() {
fi
setup_uv
# 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" | cut -d'"' -f4)
RELEASE=$(curl -fsSL https://api.github.com/repos/BiluliB/profilarr/releases/latest | grep "tag_name" | cut -d'"' -f4)
if [[ -z "$RELEASE" ]]; then
msg_error "Failed to fetch latest release version"
exit 1
@ -57,9 +57,9 @@ function update_script() {
msg_ok "Backup Created"
# Execute Update
msg_info "Updating $APP to v${RELEASE}"
msg_info "Updating $APP to ${RELEASE}"
temp_file=$(mktemp)
curl -fsSL -o "$temp_file" "https://github.com/Dictionarry-Hub/profilarr/archive/refs/tags/${RELEASE}.zip"
curl -fsSL -o "$temp_file" "https://github.com/BiluliB/profilarr/archive/refs/tags/${RELEASE}.zip"
unzip -q -o "$temp_file" -d /tmp
# Find the actual extracted directory name
@ -107,6 +107,8 @@ function update_script() {
cd /opt/${APP}/frontend || exit
npm install
npm run build
# Ensure the static directory exists before copying
mkdir -p /opt/${APP}/backend/app/static/
cp -r dist/* /opt/${APP}/backend/app/static/
msg_ok "Built Frontend"

View File

@ -20,7 +20,8 @@ $STD apt-get install -y \
unzip \
build-essential \
libyaml-dev \
python3-dev
python3-dev \
git
msg_ok "Installed Dependencies"
msg_info "Installing Python"
@ -38,13 +39,13 @@ NODE_VERSION="20" install_node_and_modules
msg_ok "Installed Node.js"
msg_info "Setup ${APPLICATION}"
RELEASE=$(curl -fsSL https://api.github.com/repos/Dictionarry-Hub/profilarr/releases/latest | grep "tag_name" | cut -d'"' -f4)
RELEASE=$(curl -fsSL https://api.github.com/repos/BiluliB/profilarr/releases/latest | grep "tag_name" | cut -d'"' -f4)
if [[ -z "$RELEASE" ]]; then
msg_error "Failed to fetch latest release version"
exit 1
fi
temp_file=$(mktemp)
$STD curl -fsSL -o "$temp_file" "https://github.com/Dictionarry-Hub/profilarr/archive/refs/tags/${RELEASE}.zip"
$STD curl -fsSL -o "$temp_file" "https://github.com/BiluliB/profilarr/archive/refs/tags/${RELEASE}.zip"
$STD unzip -q "$temp_file" -d /tmp
$STD mkdir -p /opt/${APPLICATION}
$STD mkdir -p /opt/${APPLICATION}_config
@ -91,21 +92,140 @@ cat <<EOF >/etc/systemd/system/${APPLICATION}.service
[Unit]
Description=Profilarr Profile Manager
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/opt/${APPLICATION}/backend
Environment=PATH=/opt/${APPLICATION}/venv/bin
Environment=PATH=/opt/${APPLICATION}/venv/bin:/usr/local/bin:/usr/bin:/bin
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()
Environment=PYTHONPATH=/opt/${APPLICATION}/backend
Environment=GIT_PYTHON_REFRESH=quiet
ExecStart=/opt/${APPLICATION}/venv/bin/python -m gunicorn --bind 0.0.0.0:6868 --workers 2 --timeout 120 --pythonpath /opt/${APPLICATION}/backend "app.main:create_app()"
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
EOF
$STD systemctl daemon-reload
systemctl enable -q --now ${APPLICATION}
# Test the application manually first
msg_info "Testing Application"
cd /opt/${APPLICATION}/backend
# Check if the main module exists and is importable
if ! /opt/${APPLICATION}/venv/bin/python -c "
import sys
import os
sys.path.insert(0, '/opt/${APPLICATION}/backend')
os.environ['GIT_PYTHON_REFRESH'] = 'quiet'
try:
import app.main
print('✓ app.main imported successfully')
except ImportError as e:
print(f'✗ Import error: {e}')
sys.exit(1)
except Exception as e:
print(f'✗ Other error: {e}')
sys.exit(1)
"; then
msg_error "Application import test failed"
# Try alternative approaches
msg_info "Trying alternative startup methods"
# Check if there's a direct run.py or main.py
if [[ -f "/opt/${APPLICATION}/backend/run.py" ]]; then
cat <<EOF >/etc/systemd/system/${APPLICATION}.service
[Unit]
Description=Profilarr Profile Manager
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/opt/${APPLICATION}/backend
Environment=PATH=/opt/${APPLICATION}/venv/bin:/usr/local/bin:/usr/bin:/bin
Environment=CONFIG_PATH=/opt/${APPLICATION}_config
Environment=GIT_PYTHON_REFRESH=quiet
ExecStart=/opt/${APPLICATION}/venv/bin/python run.py
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
EOF
elif [[ -f "/opt/${APPLICATION}/backend/main.py" ]]; then
cat <<EOF >/etc/systemd/system/${APPLICATION}.service
[Unit]
Description=Profilarr Profile Manager
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/opt/${APPLICATION}/backend
Environment=PATH=/opt/${APPLICATION}/venv/bin:/usr/local/bin:/usr/bin:/bin
Environment=CONFIG_PATH=/opt/${APPLICATION}_config
Environment=GIT_PYTHON_REFRESH=quiet
ExecStart=/opt/${APPLICATION}/venv/bin/python main.py
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
EOF
else
# Fallback to Flask development server
cat <<EOF >/etc/systemd/system/${APPLICATION}.service
[Unit]
Description=Profilarr Profile Manager
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/opt/${APPLICATION}/backend
Environment=PATH=/opt/${APPLICATION}/venv/bin:/usr/local/bin:/usr/bin:/bin
Environment=CONFIG_PATH=/opt/${APPLICATION}_config
Environment=GIT_PYTHON_REFRESH=quiet
Environment=FLASK_APP=app.main:create_app
Environment=FLASK_RUN_HOST=0.0.0.0
Environment=FLASK_RUN_PORT=6868
ExecStart=/opt/${APPLICATION}/venv/bin/python -m flask run
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
EOF
fi
$STD systemctl daemon-reload
fi
systemctl enable ${APPLICATION}
systemctl start ${APPLICATION}
# Wait and check status
sleep 5
if systemctl is-active --quiet ${APPLICATION}; then
msg_ok "Service started successfully"
else
msg_error "Service failed to start. Checking logs..."
journalctl -u ${APPLICATION} --no-pager -n 20
exit 1
fi
msg_ok "Created Service"
motd_ssh