forked from macexx/EAP-Controller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
110 lines (82 loc) · 3.22 KB
/
install.sh
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
#!/bin/bash
#########################################
## ENVIRONMENTAL CONFIG ##
#########################################
# Configure user nobody to match unRAID's settings config will still be run as root
usermod -u 99 nobody
usermod -g 100 nobody
usermod -d /home nobody
chown -R nobody:users /home
# Disable SSH
rm -rf /etc/service/sshd /etc/my_init.d/00_regen_ssh_host_keys.sh
#########################################
## REPOSITORIES AND DEPENDENCIES ##
#########################################
# Install Dependencies
apt-get -qq update
apt-get -qy install software-properties-common wget net-tools jsvc tzdata openjdk-8-jdk mongodb
#########################################
## FILES, SERVICES AND CONFIGURATION ##
#########################################
# Initiate config directory
mkdir -p /config
# Change Default JDK Version
update-java-alternatives -s java-1.8.0-openjdk-amd64
# Create mongod softlink
ln -s /usr/bin/mongod /opt/tplink/EAPController/bin/
# Setup Ddirectories
cat <<'EOT' > /etc/my_init.d/00_config.sh
#!/bin/bash
# Create Directories
mkdir -p /config/logs
mkdir -p /config/data
mkdir -p /config/keystore
mkdir -p /config/cert
# Checking if previous configuration exists
if [ -d "/config/data/map" ]; then
echo "Config exists, importing previous configuration!"
rm -r /opt/tplink/EAPController/data
rm -r /opt/tplink/EAPController/logs
rm -r /opt/tplink/EAPController/keystore
ln -sf /config/data /opt/tplink/EAPController/data
ln -sf /config/logs /opt/tplink/EAPController/logs
ln -sf /config/keystore /opt/tplink/EAPController/keystore
else
echo "Copying configuration from install directory to host!"
mv /opt/tplink/EAPController/data /config
mv /opt/tplink/EAPController/logs /config
mv /opt/tplink/EAPController/keystore /config
ln -sf /config/data /opt/tplink/EAPController/data
ln -sf /config/logs /opt/tplink/EAPController/logs
ln -sf /config/keystore /opt/tplink/EAPController/keystore
fi
# Checking if custom cert is available
if [ -f "/config/cert/mydomain.p12" ]; then
echo "Custom cert is available, installing..."
rm /config/keystore/eap.keystore
echo tplink | /opt/tplink/EAPController/jre/bin/keytool -importkeystore -srckeystore /config/cert/mydomain.p12 -srcstoretype PKCS12 -destkeystore /opt/tplink/EAPController/keystore/eap.keystore -deststorepass tplink -deststoretype pkcs12
fi
EOT
# Start upgrade of base system
cat <<'EOT' > /etc/my_init.d/01_start.sh
#!/bin/bash
echo "Upgrading local packages(Security) - This might take awhile(first run takes some extra time)"
apt-get update -qq
apt-get upgrade -y -o Dpkg::Options::="--force-confdef"
echo "Upgrade Done...."
chown -R root:root /opt/tplink /config
/etc/init.d/tpeap start
EOT
chmod -R +x /etc/my_init.d/
#########################################
## INTALLATION ##
#########################################
cd /tmp
pwd
wget https://static.tp-link.com/upload/software/2023/202303/20230321/Omada_SDN_Controller_v5.9.31_Linux_x64.tar.gz
tar zxvf Omada_SDN_Controller_v5.9.31_Linux_x64.tar.gz --one-top-level
chown -R root:root /tmp/Omada_SDN_Controller_v5.9.31_Linux_x64
cd Omada_SDN_Controller_v5.9.31_Linux_x64
chmod +x install.sh
sed -i '228d' install.sh
echo yes | ./install.sh