Repository navigation
Expand file tree
/
Copy pathsetup_gui_updates.sh
More file actions
executable file
·116 lines (99 loc) · 4.15 KB
/
Copy pathsetup_gui_updates.sh
File metadata and controls
executable file
·116 lines (99 loc) · 4.15 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
###############################################################################
# Client St0r - Enable GUI One-Click Updates
# This script configures passwordless sudo for the web interface to apply updates
###############################################################################
set -e
echo "========================================"
echo "Client St0r - GUI Update Setup"
echo "========================================"
echo ""
# Get current user
USERNAME=$(whoami)
echo "Configuring for user: $USERNAME"
echo ""
# Create sudoers file for git and service management
SUDOERS_FILE="/etc/sudoers.d/clientst0r-gui-updates"
echo "Creating sudoers configuration..."
cat > /tmp/clientst0r-gui-updates <<EOF
# Client St0r - GUI Update Permissions
# Allow web user to pull updates and restart services
# Git operations
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/git pull
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/git pull *
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/git fetch
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/git fetch *
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/git reset
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/git reset *
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/git rev-parse *
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/git merge-base *
# Service management
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart huduglue-gunicorn.service
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/systemctl stop huduglue-gunicorn.service
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/systemctl start huduglue-gunicorn.service
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/systemctl status huduglue-gunicorn.service
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart clientst0r-gunicorn.service
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/systemctl reload clientst0r-gunicorn.service
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart clientst0r-gunicorn
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/systemctl status clientst0r-gunicorn.service
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/systemctl daemon-reload
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/systemd-run *
# Python/pip for package installs
$USERNAME ALL=(ALL) NOPASSWD: /home/*/venv/bin/pip
$USERNAME ALL=(ALL) NOPASSWD: /home/*/venv/bin/pip install *
$USERNAME ALL=(ALL) NOPASSWD: /home/*/venv/bin/pip3
$USERNAME ALL=(ALL) NOPASSWD: /home/*/venv/bin/pip3 install *
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/pip3
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/pip3 install *
# Database migrations and management
$USERNAME ALL=(ALL) NOPASSWD: /home/*/venv/bin/python
$USERNAME ALL=(ALL) NOPASSWD: /home/*/venv/bin/python *
$USERNAME ALL=(ALL) NOPASSWD: /home/*/venv/bin/python3
$USERNAME ALL=(ALL) NOPASSWD: /home/*/venv/bin/python3 *
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/python3 */manage.py migrate *
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/python3 */manage.py collectstatic *
# Package scanner (already configured separately)
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/apt-get update
$USERNAME ALL=(ALL) NOPASSWD: /usr/bin/apt-get upgrade -y
EOF
# Validate syntax
echo "Validating sudoers syntax..."
if ! sudo visudo -c -f /tmp/clientst0r-gui-updates; then
echo "ERROR: Invalid sudoers syntax!"
rm /tmp/clientst0r-gui-updates
exit 1
fi
echo "✓ Syntax valid"
# Install sudoers file
echo "Installing sudoers file..."
sudo cp /tmp/clientst0r-gui-updates "$SUDOERS_FILE"
sudo chmod 0440 "$SUDOERS_FILE"
sudo chown root:root "$SUDOERS_FILE"
rm /tmp/clientst0r-gui-updates
echo "✓ Sudoers file installed"
echo ""
# Test sudo access
echo "Testing sudo permissions..."
if sudo -n git --version >/dev/null 2>&1; then
echo "✓ Git: OK"
else
echo "⚠ Git: Failed (may need to logout/login)"
fi
if sudo -n systemctl --version >/dev/null 2>&1; then
echo "✓ Systemctl: OK"
else
echo "⚠ Systemctl: Failed (may need to logout/login)"
fi
echo ""
echo "========================================"
echo "✓ GUI Update Setup Complete!"
echo "========================================"
echo ""
echo "You can now use the web interface to:"
echo " • Click 'Apply Update' button"
echo " • Updates will pull from Git automatically"
echo " • Services will restart automatically"
echo " • No SSH/command-line needed!"
echo ""
echo "Go to: Settings → System Updates → Click 'Apply Update'"
echo ""