OSDN Git Service

Initial commit
[rebornos/cnchi-gnome-mac-osdn.git] / test-cnchi.sh
1 #  Copyright © 2016-2019 RebornOS
2 #
3 #  This file is part of RebornOS.
4 #
5 #  Reborn OS is free software; you can redistribute it and/or modify
6 #  it under the terms of the GNU General Public License as published by
7 #  the Free Software Foundation; either version 3 of the License, or
8 #  (at your option) any later version.
9 #
10 #  Reborn OS is distributed in the hope that it will be useful,
11 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 #  GNU General Public License for more details.
14 #
15 #  The following additional terms are in effect as per Section 7 of the license:
16 #
17 #  The preservation of all legal notices and author attributions in
18 #  the material or in the Appropriate Legal Notices displayed
19 #  by works containing it is required.
20 #
21 #  You should have received a copy of the GNU General Public License
22 #  along with Reborn OS; If not, see <http://www.gnu.org/licenses/>.
23
24 #!/bin/bash
25 ##############################
26 # Script to download and install Cnchi #
27 ##############################
28
29
30 # Defining Variables
31 export CNCHI_GIT_BRANCH="0.16.21"
32 export CNCHI_GIT_URL="https://github.com/Antergos/Cnchi/archive/${CNCHI_GIT_BRANCH}.zip"
33 export script_path="/usr/share"
34 export REBORN="/usr/share/cnchi/reborn"
35
36 QUESTION(){
37 echo
38 echo "Please select your preferred course of action:"
39 echo
40 options=("Remove all instances of Cnchi from my system" "Build Cnchi" "Quit")
41 select opt in "${options[@]}"
42 do
43     case $opt in
44         "Remove all instances of Cnchi from my system")
45             REMOVE;break;;
46         "Build Cnchi")
47             RUN;break;;
48         "Quit")
49             break;;
50         *) echo "ERROR!!! ERROR!!!! SOUND THE ALARM!!!"
51             echo "Sadly, option $REPLY is not possible! Please select either option 1, 2, or 3 instead. Thank you!";;
52     esac
53 done
54 }
55
56 # Removing Cnchi files if they exist
57 REMOVE(){
58 echo
59 echo "REMOVING ALL INSTALLED INSTANCES OF CNCHI..."
60 if [ -f /usr/share/cnchi/bin/cnchi ]; then
61 rm -rf /usr/share/cnchi
62 rm -rf /var/log/cnchi
63 rm -f /usr/bin/cnchi
64 rm -f /usr/bin/cnchi-start.sh
65 rm -f /usr/share/applications/antergos-install.desktop
66 rm -f /usr/share/applications/cnchi.desktop
67 rm -f /usr/share/pixmaps/cnchi.png
68 fi
69 echo "DONE"
70 }
71 # Downloading and installing Cnchi
72 INSTALL(){
73 echo
74 echo "#########################################################"
75 echo "########## DOWNLOADING & INSTALLING CNCHI... ############"
76 echo "#########################################################"
77 echo
78     wget "${CNCHI_GIT_URL}" -O ${script_path}/cnchi-git.zip
79     unzip ${script_path}/cnchi-git.zip -d ${script_path}
80     rm -f ${script_path}/cnchi-git.zip
81     CNCHI_SRC="${script_path}/Cnchi-${CNCHI_GIT_BRANCH}"
82         install -d ${script_path}/{cnchi,locale}
83         install -Dm755 "${CNCHI_SRC}/bin/cnchi" "/usr/bin/cnchi"
84          echo
85          echo "COPIED STARTUP FILE OVER"
86          echo
87         install -Dm755 "${CNCHI_SRC}/cnchi.desktop" "/usr/share/applications/cnchi.desktop"
88          echo
89          echo "COPIED DESKTOP FILE OVER"
90          echo
91         install -Dm644 "${CNCHI_SRC}/data/images/antergos/antergos-icon.png" "/usr/share/pixmaps/cnchi.png"
92          echo
93          echo "COPIED CNCHI ICON OVER"
94          echo
95     # TODO: This should be included in Cnchi's src code as a separate file
96     # (as both files are needed to run cnchi)
97     sed -r -i 's|\/usr.+ -v|pkexec /usr/share/cnchi/bin/cnchi -s bugsnag|g' "/usr/bin/cnchi"
98     echo
99     echo "MODIFIED STARTUP COMMAND FOR CNCHI"
100     echo
101     for i in ${CNCHI_SRC}/src ${CNCHI_SRC}/bin ${CNCHI_SRC}/data ${CNCHI_SRC}/scripts ${CNCHI_SRC}/ui; do
102         cp -R ${i} "${script_path}/cnchi/"
103         echo
104         echo "COPIED MAIN CNCHI'S SUBDIRECTORIES OVER TO BUILD FOLDER"
105         echo
106     done
107     for files in ${CNCHI_SRC}/po/*; do
108         if [ -f "$files" ] && [ "$files" != 'po/cnchi.pot' ]; then
109             STRING_PO=`echo ${files#*/}`
110             STRING=`echo ${STRING_PO%.po}`
111             mkdir -p /usr/share/locale/${STRING}/LC_MESSAGES
112             msgfmt $files -o /usr/share/locale/${STRING}/LC_MESSAGES/cnchi.mo
113             echo "${STRING} installed..."
114             echo "CNCHI IS NOW BUILT"
115         fi
116     done
117 rm -rf ${script_path}/Cnchi-${CNCHI_GIT_BRANCH}
118 }
119
120 # Ask whether or not to use experimental files for Cnchi
121 ASK(){
122 echo
123 echo
124 echo "Please select your preferred course of action:"
125 echo
126 options=("Use our official Cnchi files" "Do not use modified Cnchi files" "Use your own files instead" "Setup System for Reborn installation" "Quit")
127 select opt in "${options[@]}"
128 do
129     case $opt in
130         "Use our official Cnchi files")
131             DOWNLOAD_SIMPLE;break;;
132         "Do not use modified Cnchi files")
133             ANTERGOS;break;;
134         "Use your own files instead")
135             FILES;break;;
136         "Setup System for Reborn installation")
137             DOWNLOAD_ADVANCED;break;;
138         "Quit")
139             break
140             ;;
141         *) echo "ERROR!!! ERROR!!!! SOUND THE ALARM!!!"
142             echo "Sadly, option $REPLY is not possible! Please select either option 1, 2, 3, 4, or 5 instead. Thank you!";;
143     esac
144 done
145 }
146
147 # Use plain old Antergos files (useful for testing sometimes)
148
149 ANTERGOS(){
150 echo
151 echo
152 echo "Nice choice! I know I use this one sometimes to test things myself as well, when I need more control with files"
153 echo "Just remember - have fun and continue on! Your work truly means a lot to us at Reborn OS."
154 echo
155 echo "DOWNLOADING A FEW FILES TO HELP CNCHI START PROPERLY FOR YOU..."
156 echo
157 echo
158 cd /
159 cd /usr/share/cnchi/
160 mkdir $REBORN
161 cd $REBORN/
162 git clone https://gitlab.com/RebornOS/RebornOS.git --recursive
163 cd /
164 cd /usr/bin/
165 if [ -f /usr/bin/cnchi-start.sh ]; then
166 rm -f /usr/bin/cnchi-start.sh
167 fi
168 wget https://gitlab.com/RebornOS/RebornOS/raw/master/airootfs/usr/bin/cnchi-start.sh
169 chmod +x /usr/bin/cnchi-start.sh
170 cd /
171 cd /usr/share/applications/
172 if [ -f /usr/share/applications/cnchi.desktop ]; then
173 rm -f /usr/share/applications/cnchi.desktop
174 fi
175 if [ -f /usr/share/applications/antergos-install.desktop ]; then
176 rm -f /usr/share/applications/antergos-install.desktop
177 fi
178 cp $REBORN/RebornOS/airootfs/usr/share/applications/antergos-install.desktop /usr/share/applications/
179 echo
180 echo "DONE WITH EVERYTHING!"
181 echo "ENJOY ANTERGOS' CNCHI"
182 }
183
184 # Use your own files for Cnchi
185 FILES(){
186 echo
187 echo
188 echo "Fabulous! I see you're quite adventurous' :)"
189 echo "Well, have fun and happy hacking."
190 yad --center --width=350 --height=100 --form --separator='' --title="Select" --text="Select Disired Directory" --save --field="":CDIR > /tmp/reborn-directory.txt
191 SAVING=$(sed '1q;d' /tmp/reborn-directory.txt)
192 cd $SAVING
193 echo
194 echo "DOWNLOADING SPECIAL IMAGE FILES FOR CNCHI. THEN INSTALLING YOUR FILES AS WELL..."
195 echo
196 echo
197 cd /
198 cd /usr/share/cnchi/
199 mkdir $REBORN
200 cd $REBORN/
201 git clone https://gitlab.com/RebornOS/RebornOS.git --recursive
202 cp -r $SAVING $REBORN/Cnchi
203 mv $REBORN/RebornOS/images $REBORN/images
204 cd /
205 cd /usr/bin/
206 if [ -f /usr/bin/cnchi-start.sh ]; then
207 rm -f /usr/bin/cnchi-start.sh
208 fi
209 wget https://gitlab.com/RebornOS/RebornOS/raw/master/airootfs/usr/bin/cnchi-start.sh
210 chmod +x /usr/bin/cnchi-start.sh
211 cd /
212 cd /usr/share/applications/
213 if [ -f /usr/share/applications/cnchi.desktop ]; then
214 rm -f /usr/share/applications/cnchi.desktop
215 fi
216 if [ -f /usr/share/applications/antergos-install.desktop ]; then
217 rm -f /usr/share/applications/antergos-install.desktop
218 fi
219 cp $REBORN/RebornOS/airootfs/usr/share/applications/antergos-install.desktop /usr/share/applications/
220 echo "DONE"
221 rm -f /tmp/reborn-directory.txt
222 CUSTOMIZE
223 }
224
225 # Download Reborn's normal Cnchi files
226 DOWNLOAD_SIMPLE(){
227 echo
228 echo
229 echo "Fabulous! Checking out Reborn I see :)"
230 echo "Well, have fun and happy hacking."
231 echo
232 echo "DOWNLOADING SPECIAL REBORN FILES FOR CNCHI..."
233 echo
234 echo
235 cd /
236 cd /usr/share/cnchi/
237 mkdir $REBORN
238 cd $REBORN/
239 git clone https://gitlab.com/RebornOS/RebornOS.git --recursive
240 mv $REBORN/RebornOS/Cnchi $REBORN/Cnchi
241 mv $REBORN/RebornOS/images $REBORN/images
242 cd /
243 cd /usr/bin/
244 if [ -f /usr/bin/cnchi-start.sh ]; then
245 rm -f /usr/bin/cnchi-start.sh
246 fi
247 wget https://gitlab.com/RebornOS/RebornOS/raw/master/airootfs/usr/bin/cnchi-start.sh
248 chmod +x /usr/bin/cnchi-start.sh
249 cd /
250 cd /usr/share/applications/
251 if [ -f /usr/share/applications/cnchi.desktop ]; then
252 rm -f /usr/share/applications/cnchi.desktop
253 fi
254 if [ -f /usr/share/applications/antergos-install.desktop ]; then
255 rm -f /usr/share/applications/antergos-install.desktop
256 fi
257 cp $REBORN/RebornOS/airootfs/usr/share/applications/antergos-install.desktop /usr/share/applications/
258 echo "DONE"
259 CUSTOMIZE
260 }
261
262 # Install REBORN
263 DONWLOAD_ADVANCED() {
264   echo
265   echo
266   echo "Fabulous! Welcome to Reborn :)"
267   echo "Well, have fun and happy hacking."
268   echo
269   echo "DOWNLOADING SPECIAL REBORN FILES FOR CNCHI..."
270   echo
271   echo
272   cd /
273   cd /usr/share/cnchi/
274   mkdir $REBORN
275   cd $REBORN/
276   git clone https://gitlab.com/RebornOS/RebornOS.git --recursive
277   mv $REBORN/RebornOS/Cnchi $REBORN/Cnchi
278   mv $REBORN/RebornOS/images $REBORN/images
279   cd /
280   cd /usr/bin/
281   if [ -f /usr/bin/cnchi-start.sh ]; then
282   rm -f /usr/bin/cnchi-start.sh
283   fi
284   wget https://gitlab.com/RebornOS/RebornOS/raw/master/airootfs/usr/bin/cnchi-start.sh
285   chmod +x /usr/bin/cnchi-start.sh
286   cd /
287   cd /usr/share/applications/
288   if [ -f /usr/share/applications/cnchi.desktop ]; then
289   rm -f /usr/share/applications/cnchi.desktop
290   fi
291   if [ -f /usr/share/applications/antergos-install.desktop ]; then
292   rm -f /usr/share/applications/antergos-install.desktop
293   fi
294   cp $REBORN/RebornOS/airootfs/usr/share/applications/antergos-install.desktop /usr/share/applications/
295   #Use lightdm.conf from local direcectory instead of default one
296   echo "Removing unnecessary lightdm.conf"
297   rm /etc/lightdm/lightdm.conf
298   echo "Copying correct lightdm.conf file over"
299   cp $REBORN/airootfs/etc/lightdm/lightdm.conf /etc/lightdm/
300   echo "DONE"
301   echo
302   #Use sddm.conf from local direcectory instead of default one
303   echo "Removing unnecessary sddm.conf"
304   rm /etc/sddm.conf
305   echo "Copying correct sddm.conf file over"
306   cp $REBORN/etc/sddm.conf /etc/
307   echo "DONE"
308   echo
309   #Copy Antergos Mirrorlist
310   echo "Setting up Antergos and Reborn Mirrorlist"
311   mkdir -p /etc/pacman.d
312   cp $REBORN/airootfs/etc/antergos-mirrorlist /etc/pacman.d/
313   cp $REBORN/airootfs/etc/reborn-mirrorlist /etc/pacman.d/
314   echo "DONE"
315   echo
316   #Copy pacman-init.service over
317   echo "Copying pacman-init.service"
318   cp $REBORN/pacman-init.service /etc/systemd/system/
319   echo "DONE"
320   echo
321   #Replace pacman.conf with Reborn's
322   echo "Replacing pacman.conf with Reborn's"
323   rm /etc/pacman.conf
324   cp $REBORN/Cnchi/pacman.conf /airootfs/etc/
325   cp $REBORN/Cnchi/pacman.conf /usr/share/cnchi/
326   cp $REBORN/Cnchi/pacman2.conf /
327   mv /pacman2.conf /tmp/pacman.conf
328   echo "DONE"
329   echo
330   CUSTOMIZE
331 }
332
333 # Customize Cnchi for Reborn OS
334 CUSTOMIZE(){
335 echo
336 echo
337 echo "MOVING DOWNLOADED FILES OVER..."
338 echo
339 echo
340
341 #Editting Cnchi
342 echo "Moving Cnchi files over..."
343
344 cp $REBORN/Cnchi/packages.xml /usr/share/cnchi/data/
345 cp $REBORN/Cnchi/pacman.tmpl /usr/share/cnchi/data/
346 cp $REBORN/Cnchi/features_info.py /usr/share/cnchi/src/
347 cp $REBORN/Cnchi/features.py /usr/share/cnchi/src/pages/
348 cp $REBORN/Cnchi/desktop_info.py /usr/share/cnchi/src/
349 cp $REBORN/Cnchi/grub2.py /usr/share/cnchi/src/installation/boot/
350 cp $REBORN/Cnchi/10_antergos /usr/share/cnchi/scripts/
351 cp $REBORN/Cnchi/systemd_boot.py /usr/share/cnchi/src/installation/boot/
352 cp $REBORN/Cnchi/postinstall.sh /usr/share/cnchi/scripts/
353 cp $REBORN/Cnchi/info.py /usr/share/cnchi/src/
354 cp $REBORN/Cnchi/show_message.py /usr/share/cnchi/src/
355 cp $REBORN/Cnchi/slides.py /usr/share/cnchi/src/pages/
356 cp $REBORN/Cnchi/check.py /usr/share/cnchi/src/pages/
357 cp $REBORN/Cnchi/welcome.py /usr/share/cnchi/src/pages/
358 cp $REBORN/Cnchi/antergos-logo-mini2.png /usr/share/cnchi/data/images/antergos/
359 cp $REBORN/Cnchi/20-intel.conf /usr/share/cnchi/
360 cp $REBORN/Cnchi/lightdm-webkit2-greeter.conf /usr/share/cnchi/
361 cp $REBORN/Cnchi/1.png /usr/share/cnchi/data/images/slides/
362 cp $REBORN/Cnchi/2.png /usr/share/cnchi/data/images/slides/
363 cp $REBORN/Cnchi/3.png /usr/share/cnchi/data/images/slides/
364 cp $REBORN/Cnchi/sddm.conf /usr/share/cnchi/
365 cp $REBORN/airootfs/usr/share/applications/cnchi.png /usr/share/pixmaps/
366 cp $REBORN/Cnchi/antergos-icon.png /usr/share/cnchi/data/images/antergos/antergos-icon.png
367 cp $REBORN/scripts/tint2-start.desktop /usr/share/cnchi/
368 cp $REBORN/scripts/conky-start.desktop /usr/share/cnchi/
369 cp $REBORN/scripts/obmenu-gen.desktop /usr/share/cnchi/
370 cp $REBORN/scripts/plymouth-reborn.desktop /usr/share/cnchi/
371 cp $REBORN/scripts/mate-panel.desktop /usr/share/cnchi/
372 cp $REBORN/scripts/plymouth.sh /usr/share/cnchi/
373 cp $REBORN/scripts/flatpak.sh /usr/share/cnchi/
374 cp $REBORN/scripts/pkcon.sh /usr/share/cnchi/
375 cp $REBORN/scripts/pkcon2.sh /usr/share/cnchi/
376 cp $REBORN/scripts/flatpak.desktop /usr/share/cnchi/
377 cp $REBORN/scripts/update.desktop /usr/share/cnchi/
378 cp $REBORN/scripts/openbox-config.sh /usr/share/cnchi/
379 cp $REBORN/scripts/deepin-fix.sh /usr/share/cnchi/
380 cp $REBORN/scripts/deepin-fix.service /usr/share/cnchi/
381 cp $REBORN/images/pantheon.png /usr/share/cnchi/data/images/desktops/
382 cp $REBORN/images/apricity.png /usr/share/cnchi/data/images/desktops/
383 cp $REBORN/images/deepin.png /usr/share/cnchi/data/images/desktops/
384 cp $REBORN/images/cinnamon.png /usr/share/cnchi/data/images/desktops/
385 cp $REBORN/images/windows.png /usr/share/cnchi/data/images/desktops/
386 cp $REBORN/images/kde.png /usr/share/cnchi/data/images/desktops/
387 cp $REBORN/images/i3.png /usr/share/cnchi/data/images/desktops/
388 cp $REBORN/images/lxqt.png /usr/share/cnchi/data/images/desktops/
389 cp $REBORN/images/openbox.png /usr/share/cnchi/data/images/desktops/
390 cp $REBORN/images/enlightenment.png /usr/share/cnchi/data/images/desktops/
391 cp $REBORN/images/xfce.png /usr/share/cnchi/data/images/desktops/
392 cp $REBORN/images/desktop-environment-apricity.svg /usr/share/cnchi/data/icons/scalable/
393 cp $REBORN/images/desktop-environment-pantheon.svg /usr/share/cnchi/data/icons/scalable/
394 cp $REBORN/images/desktop-environment-windows.svg /usr/share/cnchi/data/icons/scalable/
395 cp $REBORN/images/desktop-environment-budgie.svg /usr/share/cnchi/data/icons/scalable/
396 cp $REBORN/images/desktop-environment-i3.svg /usr/share/cnchi/data/icons/scalable/
397 cp $REBORN/Cnchi/reborn-mirrorlist /etc/pacman.d/
398 echo "DONE"
399 echo
400 echo "Replacing Antergos mentions with Reborn"
401 sed -i "s/Antergos/Reborn/g" /usr/share/cnchi/src/pages/advanced.py
402 sed -i "s/Antergos/Reborn/g" /usr/share/cnchi/src/pages/alongside.py
403 sed -i "s/Antergos/Reborn/g" /usr/share/cnchi/src/pages/ask.py
404 sed -i "s/Antergos/Reborn/g" /usr/share/cnchi/src/pages/automatic.py
405 sed -i "s/Antergos/Reborn/g" /usr/share/cnchi/src/pages/check.py
406 sed -i "s/Antergos/Reborn/g" /usr/share/cnchi/src/pages/gtkbasebox.py
407 sed -i "s/Antergos/Reborn/g" /usr/share/cnchi/src/pages/keymap.py
408 sed -i "s/Antergos/Reborn/g" /usr/share/cnchi/src/pages/language.py
409 sed -i "s/Antergos/Reborn/g" /usr/share/cnchi/src/pages/location.py
410 sed -i "s/Antergos/Reborn/g" /usr/share/cnchi/src/installation/process.py
411 sed -i "s/Antergos/Reborn/g" /usr/share/cnchi/src/pages/slides.py
412 sed -i "s/Antergos/Reborn/g" /usr/share/cnchi/src/pages/summary.py
413 sed -i "s/Antergos/Reborn/g" /usr/share/cnchi/src/pages/timezone.py
414 sed -i "s/Antergos/Reborn/g" /usr/share/cnchi/src/pages/user_info.py
415 sed -i "s/Antergos/Reborn/g" /usr/share/cnchi/src/pages/wireless.py
416 sed -i "s/Antergos/Reborn/g" /usr/share/cnchi/src/pages/zfs.py
417 sed -i "s/Antergos/Reborn/g" /usr/share/cnchi/src/pages/desktop.py
418 sed -i "s/gnome/deepin/g" /usr/share/cnchi/src/pages/desktop.py
419 #sed -i "s/Antergos/Reborn/g" ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/encfs.py
420 sed -i "s/Antergos/Reborn/g" /usr/share/cnchi/src/main_window.py
421 echo "DONE"
422 }
423
424 RUN(){
425 echo
426 echo
427 echo "YAY! Thank you for your help in maintaining Reborn."
428 echo "We surely need it! So have fun, and feel free to"
429 echo "message me (Keegan) anytime you want. Got questions?"
430 echo "Just ask! Thanks, and good luck."
431 echo
432 echo
433 echo
434 REMOVE
435 INSTALL
436 ASK
437 }
438
439 export -f QUESTION DOWNLOAD_SIMPLE DOWNLOAD_ADVANCED ASK CUSTOMIZE INSTALL REMOVE RUN ANTERGOS
440
441 QUESTION