forked from lyarinet/Samba-Manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·132 lines (114 loc) · 3.62 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·132 lines (114 loc) · 3.62 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
#
# Samba Manager Installation Script
#
# Check if script is running as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root. Please use sudo."
exit 1
fi
echo "=========================================================="
echo " Samba Manager Installation Script"
echo "=========================================================="
echo ""
# Check if Python 3 is installed
if ! command -v python3 &> /dev/null; then
echo "Python 3 is not installed. Installing..."
apt-get update
apt-get install -y python3 python3-pip python3-venv
else
echo "Python 3 is already installed."
fi
# Check if Samba is installed
if ! command -v smbd &> /dev/null; then
echo "Samba is not installed. Installing..."
apt-get update
apt-get install -y samba samba-common smbclient
else
echo "Samba is already installed."
fi
# Create smbusers group if it doesn't exist
if ! getent group smbusers > /dev/null; then
echo "Creating smbusers group..."
groupadd smbusers
else
echo "smbusers group already exists."
fi
# Install directory
INSTALL_DIR="/opt/samba-manager"
echo "Installing Samba Manager to $INSTALL_DIR..."
# Create installation directory
mkdir -p $INSTALL_DIR
# Copy all files to installation directory
cp -r * $INSTALL_DIR
# Make sure uninstall script is executable
if [ -f "$INSTALL_DIR/uninstall.sh" ]; then
chmod +x $INSTALL_DIR/uninstall.sh
# Create a symlink to the uninstall script
ln -sf $INSTALL_DIR/uninstall.sh /usr/local/bin/samba-manager-uninstall
echo "Created uninstall command: samba-manager-uninstall"
fi
# Make sure network fix script is executable
if [ -f "$INSTALL_DIR/fix_network_access.sh" ]; then
chmod +x $INSTALL_DIR/fix_network_access.sh
echo "Network access fix script is ready."
fi
# Create a virtual environment
echo "Creating Python virtual environment..."
cd $INSTALL_DIR
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
# Create a systemd service file
echo "Creating systemd service file..."
cat > /etc/systemd/system/samba-manager.service << EOF
[Unit]
Description=Samba Manager Web Interface
After=network.target
[Service]
User=root
WorkingDirectory=$INSTALL_DIR
ExecStart=$INSTALL_DIR/venv/bin/python $INSTALL_DIR/run.py --port 5000
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
# Create a convenient run script
echo "Creating run script..."
cat > /usr/local/bin/samba-manager << EOF
#!/bin/bash
cd $INSTALL_DIR
./run_with_sudo.sh
EOF
chmod +x /usr/local/bin/samba-manager
# Reload systemd, enable and start the service
echo "Enabling and starting Samba Manager service..."
systemctl daemon-reload
systemctl enable samba-manager.service
systemctl start samba-manager.service
echo ""
echo "=========================================================="
echo " Samba Manager Installation Complete!"
echo "=========================================================="
echo ""
echo "The Samba Manager web interface is running at:"
echo "http://$(hostname -I | awk '{print $1}'):5000"
echo ""
echo "Default login credentials:"
echo "Username: admin"
echo "Password: admin"
echo ""
echo "IMPORTANT: Change the default password after your first login!"
echo ""
echo "To control the service:"
echo " Start: systemctl start samba-manager.service"
echo " Stop: systemctl stop samba-manager.service"
echo " Restart: systemctl restart samba-manager.service"
echo " Status: systemctl status samba-manager.service"
echo ""
echo "To run Samba Manager manually, use:"
echo " samba-manager"
echo ""
echo "Installation directory: $INSTALL_DIR"
echo "=========================================================="