-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathinstall
executable file
·234 lines (192 loc) · 9.51 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
#!/bin/bash
# --------------------------------------------------------------------------
# Arquivo de instalação do riso e do risos
# --------------------------------------------------------------------------
dep_cli="avahi-utils rtorrent screen ntfsprogs ssh"
dep_ser="avahi-utils avahi-daemon bittorrent rtorrent screen ntfsprogs grub2 ssh coreutils mkisofs genisoimage findutils bash passwd sed squashfs-tools casper rsync mount eject libdebian-installer4 os-prober ubiquity user-setup discover1 discover laptop-detect syslinux xterm util-linux xresprobe cdrecord"
# modificaçao -- dessabila o UUID no ubuntu
DisableUUID(){
b=`cat /boot/grub/grub.cfg | grep =UUID=`
uuidUbuntu=`(cut -d ' ' -f3 | cut -d '=' -f2-3)<<<${b}`
partLinux=`os-prober | grep linux | cut -d ':' -f1`
sed "s|${uuidUbuntu}|${partLinux}|g" -i /boot/grub/grub.cfg
}
menu() {
apt-get install -y dialog
opcao=$( dialog --stdout \
--title 'Instalação do RISO' \
--ok-label 'Confirmar' \
--checklist 'Deseja instalar:' \
0 0 0 \
RISOS '' ON \
RISO '' ON )
# De acordo com a opção escolhida, executa funcoes
case $opcao in
'"RISOS"') instala_risos;;
'"RISO"') instala_riso;;
'"RISOS" "RISO"') instala_riso; instala_risos;;
esac
}
instala_riso() {
echo "Instalando Cliente (RISO)..."
echo "Baixando dependências..."
apt-get install -y $dep_cli
echo "Criando árvore de diretórios..."
mkdir -p /usr/riso
mkdir -p /usr/riso/imagens
echo "Criando arquivo de inicialização..."
echo '#!/bin/bash' > /usr/bin/riso
echo '/usr/riso/riso $@' >> /usr/bin/riso
chmod +x /usr/bin/riso
echo "Movendo script..."
cp ./src/riso /usr/riso/riso
cp ./src/quitRTorrent.sh /usr/riso/quitRTorrent.sh
chmod +x /usr/riso/quitRTorrent.sh
chmod +x /usr/riso/riso
cp ./conf/riso.conf /usr/riso/riso.conf
cp ./conf/.rtorrent.rc /root
echo "Sistema instalado com sucesso."
echo "Tente digitar 'riso' para iniciar."
}
instala_risos() {
echo "Instalando Servidor (RISOS)..."
servidor=`ip route | grep src | cut -d ' ' -f12`
echo "Liberando login como root..."
echo -n "root:" > /etc/shadow.tmp
pass=`cat /etc/shadow | grep \`who | awk 'NR==1{print $1}'\` | cut -d':' -f2`
echo -n "${pass}:" >> /etc/shadow.tmp
cat /etc/shadow | grep root | cut -d':' -f3,4,5,6,7,8,9 >> /etc/shadow.tmp
cat /etc/shadow | grep -v root >> /etc/shadow.tmp
mv /etc/shadow.tmp /etc/shadow
echo "Baixando dependências..."
apt-get install -y $dep_ser
echo "Criando árvore de diretórios..."
mkdir -p /usr/riso
mkdir -p /usr/riso/imagens
echo "Criando arquivo de inicialização..."
echo '#!/bin/bash' > /usr/bin/risos
echo '/usr/riso/risos $@' >> /usr/bin/risos
chmod +x /usr/bin/risos
echo "Movendo script..."
cp ./src/risos /usr/riso/risos
chmod +x /usr/riso/risos
echo "Gerando chaves rsa..."
ssh-keygen -t 'rsa' -f '/root/.ssh/id_rsa' -N ''
su -c "cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys2"
echo "Criando variáveis de configuração..."
#Pega partições
partrec=`df -T | awk 'NR==2{print $1}'`
partwindows=`os-prober | grep Windows | cut -d':' -f1`
partlinux=`os-prober | grep linux | cut -d':' -f1`
partswap=`blkid | grep swap | grep -v ram | cut -d':' -f1`
#Pega sistema de arquivo das partiçoes.
sa_partrec=`df -T | awk 'NR==2{print $2}'`
sa_partlinux=`blkid ${partlinux} | cut -d'"' -f4`
sa_partwindows=`blkid ${partwindows} | cut -d'"' -f4`
#Prepara grub2
#sed s/'GRUB_DEFAULT=0'/'GRUB_DEFAULT=1'/g -i /etc/default/grub
sed s/'GRUB_DISTRIBUTOR=*'/'#GRUB_DISTRIBUTOR='/g -i /etc/default/grub
echo 'GRUB_DISTRIBUTOR=Recuperacao' >> /etc/default/grub
sed s/'#GRUB_DISABLE_LINUX_UUID=true'/'GRUB_DISABLE_LINUX_UUID=true'/g -i /etc/default/grub
sed s/'#GRUB_DISABLE_LINUX_RECOVERY="true"'/'GRUB_DISABLE_LINUX_RECOVERY="true"'/g -i /etc/default/grub
rm -f /etc/grub.d/20_memtest86+
mv /etc/grub.d/10_linux /etc/grub.d/50_linux
update-grub
DisableUUID #modificacao
#Cria riso.service
echo "Criando arquivo de configuração..."
echo '<?xml version="1.0" standalone="no"?><!--*-nxml-*-->' > /etc/avahi/services/riso.service
echo '<!DOCTYPE service-group SYSTEM "avahi-service.dtd">' >> /etc/avahi/services/riso.service
echo '' >> /etc/avahi/services/riso.service
echo '<!--riso.service -->' >> /etc/avahi/services/riso.service
echo '' >> /etc/avahi/services/riso.service
echo '<!--' >> /etc/avahi/services/riso.service
echo ' Arquivo com as variáveis de configuração do riso.' >> /etc/avahi/services/riso.service
echo ' Essas variáveis são usadas para efetuar a comunicação do servidor riso(risos) com os cliente(riso).' >> /etc/avahi/services/riso.service
echo ' Para mais informações sobre o processo ver http://avahi.org' >> /etc/avahi/services/riso.service
echo '-->' >> /etc/avahi/services/riso.service
echo '' >> /etc/avahi/services/riso.service
echo '<service-group>' >> /etc/avahi/services/riso.service
echo ' <name>Servidor RISO DECOM</name>' >> /etc/avahi/services/riso.service
echo '' >> /etc/avahi/services/riso.service
echo ' <service>' >> /etc/avahi/services/riso.service
echo ' <!--Nome do serviço-->' >> /etc/avahi/services/riso.service
echo " <type>_DECOM_RISO._tcp</type>" >> /etc/avahi/services/riso.service
echo '' >> /etc/avahi/services/riso.service
echo ' <!--Campo não é usado-->' >> /etc/avahi/services/riso.service
echo ' <port>1234</port>' >> /etc/avahi/services/riso.service
echo '' >> /etc/avahi/services/riso.service
echo ' <!--Ip do servidor-->' >> /etc/avahi/services/riso.service # modifiçaco para guarda o ip do servidor
echo " <txt-record>Servidor=$servidor</txt-record>" >> /etc/avahi/services/riso.service #
echo '' >> /etc/avahi/services/riso.service #
echo ' <!--Variáveis com sistema de arquivo das partições-->' >> /etc/avahi/services/riso.service
echo " <txt-record>sa_partrec=${sa_partrec}</txt-record>" >> /etc/avahi/services/riso.service
echo " <txt-record>sa_partlinux=${sa_partlinux}</txt-record>" >> /etc/avahi/services/riso.service
echo " <txt-record>sa_partwindows=${sa_partwindows}</txt-record>" >> /etc/avahi/services/riso.service
echo '' >> /etc/avahi/services/riso.service
echo ' <!--Variáveis com tamanho das imagens geradas no servidor-->' >> /etc/avahi/services/riso.service
echo ' <txt-record>tamlinux=123456789</txt-record>' >> /etc/avahi/services/riso.service
echo ' <txt-record>tamwindows=123456789</txt-record>' >> /etc/avahi/services/riso.service
echo '' >> /etc/avahi/services/riso.service
echo ' <!--Localização dos sistemas operacionais no HD-->' >> /etc/avahi/services/riso.service
echo " <txt-record>partswap=${partswap}</txt-record>" >> /etc/avahi/services/riso.service
echo " <txt-record>partrec=${partrec}</txt-record>" >> /etc/avahi/services/riso.service
echo " <txt-record>partlinux=${partlinux}</txt-record>" >> /etc/avahi/services/riso.service
echo " <txt-record>partwindows=${partwindows}</txt-record>" >> /etc/avahi/services/riso.service
echo '' >> /etc/avahi/services/riso.service
echo ' </service>' >> /etc/avahi/services/riso.service
echo '</service-group>' >> /etc/avahi/services/riso.service
# preinst script for remastersys
if [ -d /remastersys ]; then
mv /remastersys /home
fi
if [ -f /etc/remastersys.conf ]; then
mv /etc/remastersys.conf /etc/remastersys.conf.old
fi
if [ -f /etc/remastersys/isolinux/splash.pcx ]; then
mv /etc/remastersys/isolinux/splash.pcx /etc/remastersys/isolinux/splash.pcx.saved
fi
if [ -f /etc/remastersys/isolinux/splash.rle ]; then
mv /etc/remastersys/isolinux/splash.rle /etc/remastersys/isolinux/splash.rle.saved
fi
if [ -f /etc/remastersys/grub/splash.xpm.gz ]; then
mv /etc/remastersys/grub/splash.xpm.gz /etc/remastersys/grub/splash.xpm.gz.saved
fi
#Instalação do remastersys
mkdir -p /etc/remastersys
cp -r ./src/remastersys/remastersys/grub /etc/remastersys
cp -r ./src/remastersys/remastersys/isolinux /etc/remastersys
cp -r ./src/remastersys/remastersys/preseed /etc/remastersys
cp ./src/remastersys/remastersys.conf /etc/remastersys.conf
# postinst script for remastersys
if [ -f /etc/remastersys/isolinux/splash.pcx.saved ]; then
mv /etc/remastersys/isolinux/splash.pcx.saved /etc/remastersys/isolinux/splash.pcx
fi
if [ -f /etc/remastersys/isolinux/splash.rle.saved ]; then
mv /etc/remastersys/isolinux/splash.rle.saved /etc/remastersys/isolinux/splash.rle
fi
if [ -f /etc/remastersys/grub/splash.xpm.gz.saved ]; then
mv /etc/remastersys/grub/splash.xpm.gz.saved /etc/remastersys/isolinux/splash.xpm.gz
fi
if [ -f /etc/remastersys.conf.old ]; then
mv /etc/remastersys.conf.old /etc/remastersys.conf
fi
#Se estiver usando windows 7. Muda arquivo de boot para não usar mais UUID.
windows7=`os-prober | grep "Windows 7"`
if [ ! -z "$windows7" ]; then
echo "Configurando Windows 7..."
umount /mnt 2> /dev/null
mount ${partwindows} /mnt
cp ./conf/BCD /mnt/Boot/BCD
umount /mnt 2> /dev/null
fi
echo "Sistema instalado com sucesso"
echo "Tente risos para iniciar"
}
#Verifica se usuário é o root antes de executar.
USER=`id -u`
if [ $USER == '0' ]; then
menu
else
echo "Só o root pode fazer isso, jovenzinho!"
fi