Skip to content

Commit 7c3973c

Browse files
authored
Create Webmin Automation Script
1 parent c404aec commit 7c3973c

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

webmin.sh

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
# Installs Wordpress for a new domain
3+
# Author Istiyak Amin Santo
4+
# Installs Webmin for fun and profit
5+
6+
# Set up a repo and install
7+
function install_webmin() {
8+
if [[ $distro == "Redhat/CentOS" ]]; then
9+
cat > /etc/yum.repos.d/webmin.repo <<-EOF
10+
[Webmin]
11+
name=Webmin Distribution Neutral
12+
#baseurl=http://download.webmin.com/download/yum
13+
mirrorlist=http://download.webmin.com/download/yum/mirrorlist
14+
enabled=1
15+
EOF
16+
curl -s http://www.webmin.com/jcameron-key.asc -o "/tmp/jcameron-key.asc"
17+
rpm --import /tmp/jcameron-key.asc > /dev/null 2>&1
18+
rm -f /tmp/jcameron-key.asc
19+
yum -y -q install webmin perl-Net-SSLeay
20+
iptables -I INPUT -m tcp -p tcp --dport 10000 -j ACCEPT
21+
service iptables save > /dev/null 2>&1
22+
elif [[ $distro == "Ubuntu" ]]; then
23+
echo "deb http://download.webmin.com/download/repository sarge contrib" >> /etc/apt/sources.list
24+
echo "deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib" >> /etc/apt/sources.list
25+
wget -q http://www.webmin.com/jcameron-key.asc
26+
apt-key add jcameron-key.asc > /dev/null 2>&1
27+
rm -f jcameron-key.asc
28+
apt-get -q update > /dev/null 2>&1
29+
apt-get -q -y install webmin > /dev/null 2>&1
30+
ufw allow 10000 > /dev/null 2>&1
31+
else
32+
echo "Unsupported OS"
33+
exit 1
34+
fi
35+
}
36+
37+
function configure_firewall() {
38+
if [[ ${distro} = "Redhat/CentOS" ]]; then
39+
iptables -I INPUT -p tcp --dport 10000 -m comment --comment "Webmin" -j ACCEPT
40+
/etc/init.d/iptables save
41+
echo "Firewall open on ports 10000"
42+
elif [ ${distro} == "Ubuntu" ]; then
43+
ufw allow 10000
44+
echo "Firewall open on ports 10000"
45+
else
46+
echo "Unsupported OS. Exiting."
47+
exit 1
48+
fi
49+
}
50+
51+
52+
echo "Beginning Installation"
53+
install_webmin
54+
configure_firewall
55+
echo "Webmin installation complete. Port 10000 is open."

0 commit comments

Comments
 (0)