-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall
executable file
·150 lines (143 loc) · 5.32 KB
/
install
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash
# +----------------------------------------------------------------------------+
# | MM5D v0.6 * Growing house controlling and remote monitoring system |
# | Copyright (C) 2019-2023 Pozsár Zsolt <[email protected]> |
# | install |
# | Installer script |
# +----------------------------------------------------------------------------+
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the European Union Public License 1.1 version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.
line()
{
for ((i=0; i<${#SWCR}; i++))
do
echo -n "-"
done
echo ""
}
copy()
{
sudo cp $1 $2
echo " $1 -> $2"
}
# constans
ARCH=`uname -m`
SWN1="MM5D"
SWN2="mm5d"
SWCR=`cat documents/copyright`
SWV=`cat documents/VERSION`
INSTDIR="local"
LANGUAGES="cs de fr hr hu pl ro ru sk sl sr uk"
SUBDIRS="/usr/$INSTDIR/bin \
/usr/$INSTDIR/etc \
/usr/$INSTDIR/etc/$SWN2 \
/usr/$INSTDIR/share \
/usr/$INSTDIR/share/doc \
/usr/$INSTDIR/share/doc/$SWN2 \
/usr/$INSTDIR/share/locale \
/usr/$INSTDIR/share/$SWN2 \
/usr/$INSTDIR/share/man \
/usr/$INSTDIR/share/man/man1 \
/usr/$INSTDIR/share/man/man7 \
/usr/$INSTDIR/share/man/man8 \
/var/$INSTDIR/lib/$SWN2 \
/var/$INSTDIR/lock \
/var/$INSTDIR/log \
/var/www/ \
/var/www/html \
/var/www/html/pics"
README="/usr/$INSTDIR/share/doc/$SWN2/README"
# installer
echo -e "\n$SWN1 v$SWV installer script"
echo "$SWCR"
line
echo -e "\n This program is free software: you can redistribute it and/or modify it
under the terms of the European Union Public License 1.1 version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.\n"
sleep 3
#if ! [ -x "$(command -v apache2)" ]; then
# echo 'ERROR: Run prepare script firstly!';
# exit;
#fi
echo -e "\nInstalling..."
echo "- creating directories:"
sudo mkdir --parents /usr/$INSTDIR 2> /dev/null
for D in $SUBDIRS
do
sudo mkdir --parents $D 2> /dev/null
echo " $D"
done
for X in $LANGUAGES; do
if [ -e "messages/"$SWN2"_"$X".msg" ];
then
sudo mkdir --parents /usr/$INSTDIR/share/locale/$X 2> /dev/null
echo " /usr/$INSTDIR/share/locale/$X"
fi;
done
sudo chown root:www-data /var/www/html/pics
sudo chmod 775 /var/www/html/pics
sudo chmod 777 /var/$INSTDIR/lib/$SWN2
sudo chmod 2777 /usr/$INSTDIR/etc/$SWN2
sudo chmod 664 /usr/$INSTDIR/etc/$SWN2/envir.ini
sudo chown -R root:staff /usr/$INSTDIR/etc/$SWN2
echo "- copying files:"
copy "LICENCE" "/usr/$INSTDIR/share/doc/$SWN2/COPYING"
copy "documents/*" "/usr/$INSTDIR/share/doc/$SWN2/"
copy "manuals/*.1.gz" "/usr/$INSTDIR/share/man/man1/"
copy "manuals/*.7.gz" "/usr/$INSTDIR/share/man/man7/"
copy "manuals/*.8.gz" "/usr/$INSTDIR/share/man/man8/"
for X in $LANGUAGES; do
if [ -e "messages/"$SWN2"_"$X".msg" ];
then
copy "messages/"$SWN2"_"$X".msg" "/usr/$INSTDIR/share/locale/$X/$SWN2.msg"
fi;
done
copy "binary/*.bin" "/usr/$INSTDIR/bin/"
copy "programs/*.py" "/usr/$INSTDIR/bin/"
copy "scripts/*" "/usr/$INSTDIR/bin/"
copy "settings/cron.d/*" "/etc/cron.d/"
copy "settings/$SWN2/*.ini" "/usr/$INSTDIR/etc/$SWN2/"
copy "settings/init.d/*" "/etc/init.d/"
copy "webpage/cgi-bin/*.cgi" "/usr/lib/cgi-bin/"
copy "webpage/*.css" "/var/www/html/"
copy "webpage/*.html" "/usr/$INSTDIR/share/$SWN2/"
copy "webpage/pics/*" "/var/www/html/pics/"
sudo mkfifo /var/tmp/matrixdisplayfifo
sudo cat /etc/motd | grep -qv $SWN1 && sudo mv /etc/motd /etc/motd.orig && sudo cp settings/motd /etc/
echo "- set init.d:"
sudo /etc/init.d/$SWN2.sh stop
sudo /etc/init.d/matrixdisplay.sh stop
copy "settings/init.d/$SWN2.sh" "/etc/init.d/"
copy "settings/init.d/matrixdisplay.sh" "/etc/init.d/"
copy "settings/systemd/system/$SWN2.service" "/etc/systemd/system/"
copy "settings/systemd/system/matrixdisplay.service" "/etc/systemd/system/"
sudo ln -sf /etc/init.d/$SWN2.sh /etc/rc0.d/K01$SWN2.sh
sudo ln -sf /etc/init.d/$SWN2.sh /etc/rc2.d/S01$SWN2.sh
sudo ln -sf /etc/init.d/$SWN2.sh /etc/rc3.d/S01$SWN2.sh
sudo ln -sf /etc/init.d/$SWN2.sh /etc/rc4.d/S01$SWN2.sh
sudo ln -sf /etc/init.d/$SWN2.sh /etc/rc5.d/S01$SWN2.sh
sudo ln -sf /etc/init.d/$SWN2.sh /etc/rc6.d/K01$SWN2.sh
sudo ln -sf /etc/init.d/matrixdisplay.sh /etc/rc0.d/K02matrixdisplay.sh
sudo ln -sf /etc/init.d/matrixdisplay.sh /etc/rc2.d/S02matrixdisplay.sh
sudo ln -sf /etc/init.d/matrixdisplay.sh /etc/rc3.d/S02matrixdisplay.sh
sudo ln -sf /etc/init.d/matrixdisplay.sh /etc/rc4.d/S02matrixdisplay.sh
sudo ln -sf /etc/init.d/matrixdisplay.sh /etc/rc5.d/S02matrixdisplay.sh
sudo ln -sf /etc/init.d/matrixdisplay.sh /etc/rc6.d/K02matrixdisplay.sh
sudo systemctl daemon-reload
sudo systemctl enable $SWN2.service
sudo systemctl enable matrixdisplay.service
sudo /etc/init.d/$SWN2.sh start
sudo /etc/init.d/matrixdisplay.sh start
echo "- set cron.d:"
copy settings/cron.d/$SWN2 /etc/cron.d/
sudo /etc/init.d/cron restart
echo "- create default startpage:"
sudo /usr/$INSTDIR/bin/$SWN2-updatestartpage
echo "Done."