-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·62 lines (51 loc) · 1.7 KB
/
setup.sh
File metadata and controls
executable file
·62 lines (51 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
set -u
APP_NAME="ojp91xx-cert-renew"
INSTALL_DIR="/opt/$APP_NAME"
CONF_DIR="/etc/$APP_NAME"
SYSTEMD_DIR="/etc/systemd/system"
# Root Check
if [[ "$EUID" -ne 0 ]]; then
echo "CRITICAL: Run as root."
exit 1
fi
echo "--- Step 1: Prepare Directories ---"
mkdir -p "$INSTALL_DIR"
mkdir -p "$CONF_DIR"
echo "--- Step 2: Copy Files ---"
cp renew_cert.py issue_cert.py upload_cert.py requirements.txt "$INSTALL_DIR/"
# Handle Configs
# Handle Configs
if [[ -f "./config.env" ]]; then
echo "Found local config.env, installing it..."
cp ./config.env "$CONF_DIR/config.env"
elif [[ ! -f "$CONF_DIR/config.env" ]]; then
echo "No local config found. Installing sample (You must edit this!)..."
cp config.env.sample "$CONF_DIR/config.env"
fi
chmod 600 "$CONF_DIR/config.env"
# Handle Cloudflare INI
if [[ -f "cloudflare.ini" ]]; then
echo "Installing cloudflare.ini..."
cp cloudflare.ini "$CONF_DIR/"
chmod 600 "$CONF_DIR/cloudflare.ini"
else
echo "WARNING: cloudflare.ini not found in source. Please create it in $CONF_DIR manually."
fi
echo "--- Step 3: Python Environment (This takes a minute) ---"
if [[ ! -d "$INSTALL_DIR/.venv" ]]; then
echo "Creating venv..."
python3 -m venv "$INSTALL_DIR/.venv"
fi
echo "Installing requirements..."
"$INSTALL_DIR/.venv/bin/pip" install -r "$INSTALL_DIR/requirements.txt"
echo "Installing Playwright Browsers..."
"$INSTALL_DIR/.venv/bin/playwright" install chromium
echo "--- Step 4: Systemd Units ---"
cp "$APP_NAME.service" "$SYSTEMD_DIR/"
cp "$APP_NAME.timer" "$SYSTEMD_DIR/"
systemctl daemon-reload
echo "--- Step 5: Activation ---"
systemctl enable --now "$APP_NAME.timer"
systemctl list-timers --no-pager | grep "$APP_NAME"
echo "Done."