-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
56 lines (46 loc) · 1.46 KB
/
install.sh
File metadata and controls
56 lines (46 loc) · 1.46 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
#!/bin/bash
# Define the project directory and service name
INSTALL_DIR="/opt/print-dashboard"
SERVICE_NAME="print-monitor"
echo "Initializing HP Print Server Dashboard..."
# Ensure we are running with sudo
if [ "$EUID" -ne 0 ]; then
echo "Please run as root (use sudo ./install.sh)"
exit
fi
# Move files to the system directory
echo "Setting up project directory at $INSTALL_DIR..."
mkdir -p "$INSTALL_DIR"
cp -r ./print-dashboard/* "$INSTALL_DIR/"
# Ensure the scan directory is writable
mkdir -p "$INSTALL_DIR/static/scans"
chmod -R 777 "$INSTALL_DIR/static/scans"
# Create the systemd service file with absolute paths
echo "Creating systemd service..."
cat <<EOT > /etc/systemd/system/$SERVICE_NAME.service
[Unit]
Description=Print and Scan Dashboard
After=network.target
[Service]
ExecStart=/usr/bin/python3 $INSTALL_DIR/app.py
WorkingDirectory=$INSTALL_DIR
User=root
Restart=always
[Install]
WantedBy=multi-user.target
EOT
# Reload systemd, enable and start the service
echo "Starting service..."
systemctl daemon-reload
systemctl enable $SERVICE_NAME
systemctl start $SERVICE_NAME
# Check status
echo "-------------------------------------------------------"
if systemctl is-active --quiet $SERVICE_NAME; then
echo "Dashboard service is RUNNING."
echo "Access it at http://$(hostname).local"
else
echo "Dashboard service failed to start."
echo "Check logs with: journalctl -u $SERVICE_NAME"
fi
echo "-------------------------------------------------------"