Project

General

Profile

install-x86.sh

Alexie, 08/27/2018 04:23 PM

 
1
#!/bin/bash
2

    
3
export MYSCRIPT=`realpath $0`
4
export MYDIR=`dirname $MYSCRIPT`
5

    
6
# https://linoxide.com/linux-how-to/create-custom-live-cd-image-cubic-ubuntu/
7
# apt-add-repository ppa:cubic-wizard/release
8
# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6494C6D6997C215E
9
# apt update && apt install cubic
10

    
11
 # Determine Ubuntu version
12
UBUNTUVERSIONNAME=`grep DISTRIB_CODENAME /etc/lsb-release | cut -d "=" -f 2`
13
if [ -f "/usr/bin/lxsession" ]; then
14
  TYPE="LUBUNTU"
15
else
16
  TYPE="UBUNTU"
17
fi
18

    
19
if [ "$UBUNTUVERSIONNAME" == "bionic" ]; then
20
  echo "INFO: Detected Ubuntu '$UBUNTUVERSIONNAME'"
21
else
22
  echo "ERROR: Unknown Ubuntu '$UBUNTUVERSIONNAME'"
23
fi
24

    
25
export HOME=/root
26
export LC_ALL=C
27

    
28
# Fix Lubuntu issue
29
if [ "$TYPE" == "LUBUNTU" ]; then
30
  sed -i "s/bionic main restricted universe multiverse/bionic main restricted multiverse/" /etc/apt/sources.list
31
fi
32

    
33
# Add "domo" user
34
useradd domo -m -s /bin/bash
35
echo -e "domotiga\ndomotiga" | passwd domo
36
usermod -a -G adm,dialout,cdrom,floppy,sudo,audio,dip,video,plugdev,lpadmin domo
37

    
38
# automatic login
39
if [ "$TYPE" == "UBUNTU" ]; then
40
  sed -i "s/#  AutomaticLoginEnable = true/AutomaticLoginEnable = true/" /etc/gdm3/custom.conf
41
  sed -i "s/#  AutomaticLogin = user1/AutomaticLogin = domo/" /etc/gdm3/custom.conf
42
else
43
  cat >/etc/lightdm/lightdm.conf << EOF
44
[SeatDefaults]
45
autologin-user=domo
46
autologin-user-timeout=0
47
user-session=Lubuntu
48
greeter-session=lightdm-gtk-greeter
49
EOF
50
fi
51

    
52
# Remove not relevant packages
53
apt-get purge -y -qq libreoffice* thunderbird
54
apt-get purge -y -qq language-pack-ru-base language-pack-es-base language-pack-pt-base language-pack-fr-base language-pack-de-base language-pack-it-base language-pack-zh-hans 
55
apt-get purge -y -qq ubuntu-web-launchers
56
apt-get purge -y -qq abiword abiword-common
57
apt-get purge -y -qq firefox-locale-de firefox-locale-es firefox-locale-fr firefox-locale-it firefox-locale-pt firefox-locale-ru firefox-locale-zh-hans
58

    
59
# Configure apt source and install Gambas3
60
UBUNTUVERSIONNAME=`grep DISTRIB_CODENAME /etc/lsb-release | cut -d "=" -f 2`
61

    
62
echo "deb http://archive.ubuntu.com/ubuntu/ $UBUNTUVERSIONNAME universe" >>/etc/apt/sources.list
63
apt-add-repository -y ppa:gambas-team/gambas3
64
apt-get update
65
apt-get install -y -qq gambas3 git sharutils
66

    
67
if [ "$UBUNTUVERSIONNAME" == "bionic" ]; then
68
  # Automatic install MySQL 5.7
69
  echo "mysql-server-5.7 mysql-server/root_password password domotiga" | debconf-set-selections
70
  echo "mysql-server-5.7 mysql-server/root_password_again password domotiga" | debconf-set-selections
71
  apt-get install -y -qq mysql-server-5.7
72
else
73
  echo "@@@ Unknown codename for Ubuntu '"$UBUNTUVERSIONNAME"', expected bionic @@@"
74
  exit 1
75
fi
76

    
77
echo "INFO: Cloning DomotiGa"
78
cd /home/domo
79
git clone --single-branch https://github.com/DomotiGa/DomotiGa.git domotiga
80

    
81
if [ "$UBUNTUVERSIONNAME" == "bionic" ]; then
82
  #test -e /var/run/mysqld || install -m 755 -o mysql -g root -d /var/run/mysqld
83
  mkdir -p /var/run/mysqld
84
  install -m 755 -o mysql -g root -d /var/run/mysqld
85
  su - mysql -s /bin/sh -c "/usr/bin/mysqld_safe > /dev/null 2>&1 &"
86
fi
87

    
88
echo "INFO: Sleep 5, for MySQL to be available"
89
sleep 5
90
echo "INFO: Checking for running MySQL"
91
if [ ! -e /var/run/mysqld/mysqld.sock ]; then
92
  echo "ERROR: Weird, MySQL is not running? ... Return to a bash shell, to troubleshoot ..."
93
  bash
94
fi
95

    
96
mysqladmin -u root -pdomotiga create domotiga
97
mysql -u root -pdomotiga domotiga <domotiga/install/domotiga.sql
98
service mysql stop
99
killall -TERM mysqld
100

    
101
echo "INFO: Install required software for open-zwave library & wrapper"
102
cd /home/domo/domotiga/wrappers/domozwave
103
apt-get install -y libudev-dev libcurl4-gnutls-dev
104

    
105
echo "INFO: Checkout the open-zwave library"
106
git clone https://github.com/OpenZWave/open-zwave open-zwave
107
rm -rf /home/domo/domotiga/wrappers/domozwave/open-zwave/.git
108

    
109
echo "INFO: Compile open-zwave library"
110
cd open-zwave
111
make
112

    
113
echo "INFO: The open-zwave library is compiled, lets link it to our domozwave library"
114
cd /home/domo/domotiga/wrappers/domozwave
115
make
116
make install
117

    
118
echo "INFO: Now remove the compiled open-zwave again, we don't need it"
119
cd /home/domo/domotiga/wrappers/domozwave/open-zwave
120
make clean
121

    
122
apt-get purge -y -qq git git-man
123

    
124
# Remove downloaded packages
125
apt-get -y autoremove
126
apt-get clean
127
apt-get autoclean
128
rm -rf /var/lib/apt/lists/*
129

    
130
mkdir -p /home/domo/Desktop
131

    
132
# Create the DomotiGa3 shortcut
133
cat >/home/domo/Desktop/DomotiGa3.desktop << EOF
134
#!/usr/bin/env xdg-open
135

    
136
[Desktop Entry]
137
Version=1.0
138
Type=Application
139
Name=DomotiGa3
140
Exec='/home/domo/domotiga/DomotiGa3.gambas'
141
Icon=/home/domo/domotiga/icons/logo.png
142
StartupNotify=true
143
Terminal=false
144
TerminalOptions=
145
Encoding=UTF-8
146
Comment=
147
EOF
148

    
149
chmod a+x /home/domo/Desktop/DomotiGa3.desktop
150

    
151

    
152
if [ "$TYPE" == "UBUNTU" ]; then
153
  cd ~
154

    
155
#cat >~/root.uue << EOF
156
#begin 644 root.tar.gz
157
#M'XL("!6?@EL``W)O;W0N=&%R`.W2NTH#010&X(GF`2PL1"RVL#39F>S.1BL+
158
#M`]I;B*1QR(YF,9L).[."G?@$%K;VECZ$I4\@%H*-#V'AF8T2!35-$,3_@Y]S
159
#MYK+W;0Y,3PU"VU>%#H].#FTCUTZERJFP,,:Q6>`DX=Q7T9:?:D7&G(DHBKD4
160
#M;=%J,RYD'`D6\)E<?8K2.E4$`4M-;G[:-VW]C[I?]M^[5O4/9?>)RADE\./N
161
#M^=46E3HEIO0IFY2#K&>&#4N_C69#5;IL4-I&-3<R-G,9-2[+-;W7?,1<02]8
162
#MI]]LK"Y[0;EDK+;H!^'XMOP-75-NJ%WR$WV3:S99NZ7<4;OB)SY\&K_V2'FF
163
#MMGJ&CK;'SHS>UUZH+%!6_;A#Q[EL6T7-=++K:_6WT^^-SU/;ISI'=8?J/-5=
164
#M(2/96D_D1L).M66"R61-_,H/#```````````````````````_]4KWAS.=``H
165
#"````
166
#`
167
#end
168
#EOF
169

    
170
  cat >~/root.uue << EOF
171
begin 644 root.tar.gz
172
M'XL("!6?@EL\`\`W)O;W0N=&%R\`.W2NTH#010&X(GF\`2PL1"RVL#39F>S.1BL+
173
M\`]I;B*1QR(YF,9L).[."G?@\$%K;VECZ\$I4\@%H*-#V'AF8T2!35-\$,3_@Y]S
174
MYK+W;0Y,3PU"VU>%#H].#FTCUTZERJFP,,:Q6>\`DX=Q7T9:?:D7&G(DHBKD4
175
M;=%J,RYD'\`D6\)E<?8K2.E4\$\`4M-;G[:-VW]C[I?]M^[5O4/9?>)RADE\./N
176
M^=46E3HEIO0IFY2#K&>&#4N_C69#5;IL4-I&-3<R-G,9-2[+-;W7?,1<02]8
177
MI]]LK"Y[0;EDK+;H!^'XMOP-75-NJ%WR\$WV3:S99NZ7<4;OB)SY\&K_V2'FF
178
MMGJ&CK;'SHS>UUZH+%!6_;A#Q[EL6T7-=++K:_6WT^^-SU/;ISI'=8?J/-5=
179
M(2/96D_D1L).M66"R61-_,H/#\`\`\`\`\`\`\`\`\`\`\`\`\`\`\`\`\`\`\`\`\`\`\`_]4KWAS.=\`\`H
180
"\`\`\`\`
181
\`
182
end
183
EOF
184

    
185
  uudecode ~/root.uue
186
  #rm -f root.uue
187
  cd /home/domo
188
  tar -xvzf ~/root.tar.gz
189
  rm -f ~/root.tar.gz
190
fi
191

    
192
chown -R domo:domo /home/domo
193

    
194
rm -f $MYSCRIPT
195

    
196
# End