OSDN Git Service

db50504b202e8a9ae17d48d0316f2dfd52eecef3
[rebornos/cnchi-gnome-osdn.git] / Cnchi / postinstall.sh
1 #!/usr/bin/bash
2 # -*- coding: utf-8 -*-
3 #
4 #  postinstall.sh
5 #
6 #  Copyright © 2013-2016 Antergos
7 #
8 # Modifications by Rafael from RebornOS in 2020
9 #
10 #  This file is part of Cnchi.
11 #
12 #  Cnchi is free software; you can redistribute it and/or modify
13 #  it under the terms of the GNU General Public License as published by
14 #  the Free Software Foundation; either version 3 of the License, or
15 #  (at your option) any later version.
16 #
17 #  Cnchi is distributed in the hope that it will be useful,
18 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
19 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 #  GNU General Public License for more details.
21 #
22 #  The following additional terms are in effect as per Section 7 of the license:
23 #
24 #  The preservation of all legal notices and author attributions in
25 #  the material or in the Appropriate Legal Notices displayed
26 #  by works containing it is required.
27 #
28 #  You should have received a copy of the GNU General Public License
29 #  along with Cnchi; If not, see <http://www.gnu.org/licenses/>.
30 #
31 # Set xorg config files
32 set_xorg_touchpad() {
33     cp /usr/share/cnchi/scripts/postinstall/50-synaptics.conf ${CN_DESTDIR}/etc/X11/xorg.conf.d/50-synaptics.conf
34     cp /usr/share/cnchi/scripts/postinstall/99-killX.conf ${CN_DESTDIR}/etc/X11/xorg.conf.d/99-killX.conf
35
36     # Fix sensitivity for chromebooks
37     if lsmod | grep -q cyapa; then
38         cp /usr/share/cnchi/scripts/postinstall/50-cros-touchpad.conf ${CN_DESTDIR}/etc/X11/xorg.conf.d/50-cros-touchpad.conf
39     fi
40 }
41
42 set_xscreensaver() {
43     # xscreensaver config
44     cp /usr/share/cnchi/scripts/postinstall/xscreensaver ${CN_DESTDIR}/home/${CN_USER_NAME}/.xscreensaver
45     cp ${CN_DESTDIR}/home/${CN_USER_NAME}/.xscreensaver ${CN_DESTDIR}/etc/skel
46
47     if [[ -f ${CN_DESTDIR}/etc/xdg/autostart/xscreensaver.desktop ]]; then
48         rm ${CN_DESTDIR}/etc/xdg/autostart/xscreensaver.desktop
49     fi
50 }
51
52 set_gsettings() {
53     # Set gsettings input-source
54     CN_KEYBOARD=""
55     CN_INPUT_SCHEMA="${CN_DESTDIR}/usr/share/glib-2.0/schemas/90_antergos.input-sources.gschema.override"
56     if [[ "${CN_KEYBOARD_LAYOUT}" != '' ]]; then
57         if [[ "${CN_KEYBOARD_VARIANT}" != '' ]]; then
58             CN_KEYBOARD=${CN_KEYBOARD_LAYOUT}+${CN_KEYBOARD_VARIANT}
59         else
60             CN_KEYBOARD=${CN_KEYBOARD_LAYOUT}
61         fi
62         echo "[org.cinnamon.desktop.input-sources]" > ${CN_INPUT_SCHEMA}
63         echo "sources=[('xkb','${CN_KEYBOARD}')]" >> ${CN_INPUT_SCHEMA}
64         echo " " >> ${CN_INPUT_SCHEMA}
65         echo "[org.gnome.desktop.input-sources]" >> ${CN_INPUT_SCHEMA}
66         echo "sources=[('xkb','${CN_KEYBOARD}')]" >> ${CN_INPUT_SCHEMA}
67     fi
68
69     # Set default Internet browser
70     for CN_SCHEMA_OVERRIDE in ${CN_DESTDIR}/usr/share/glib-2.0/schemas/90_antergos*; do
71         if [ "${CN_BROWSER}" != "" ]; then
72             sed -i "s|chromium|${CN_BROWSER}|g" "${CN_SCHEMA_OVERRIDE}"
73         else
74             sed -i "s|'chromium.desktop',||g" "${CN_SCHEMA_OVERRIDE}"
75         fi
76     done
77
78     glib-compile-schemas "${CN_DESTDIR}/usr/share/glib-2.0/schemas"
79 }
80
81 set_dmrc() {
82     # Set session in .dmrc
83     echo "[Desktop]" > ${CN_DESTDIR}/home/${CN_USER_NAME}/.dmrc
84     echo "Session=$1" >> ${CN_DESTDIR}/home/${CN_USER_NAME}/.dmrc
85     chroot ${CN_DESTDIR} chown ${CN_USER_NAME}:users /home/${CN_USER_NAME}/.dmrc
86 }
87
88 common_settings() {
89     # Set skel directory (not needed, antergos-desktop-settings does this)
90     #cp -R ${CN_DESTDIR}/home/${CN_USER_NAME}/.config ${CN_DESTDIR}/etc/skel
91
92     # Set .bashrc (antergos-desktop-settings can't set it because it's already in bash package)
93     if [[ -f "${CN_DESTDIR}/etc/skel/bashrc" ]]; then
94         cp ${CN_DESTDIR}/etc/skel/bashrc ${CN_DESTDIR}/etc/skel/.bashrc
95         cp ${CN_DESTDIR}/etc/skel/bashrc ${CN_DESTDIR}/home/${CN_USER_NAME}/.bashrc
96     fi
97
98     # Setup root defaults
99     cp -R ${CN_DESTDIR}/etc/skel/. ${CN_DESTDIR}/root
100 }
101
102 gnome_settings() {
103     set_gsettings
104     set_xscreensaver
105
106     set_dmrc gnome
107 }
108
109 cinnamon_settings() {
110     set_gsettings
111     set_xscreensaver
112
113     # Copy menu@cinnamon.org.json to set menu icon
114     mkdir -p ${CN_DESTDIR}/home/${CN_USER_NAME}/.cinnamon/configs/menu@cinnamon.org/
115     cp -f /usr/share/cnchi/scripts/postinstall/menu@cinnamon.org.json ${CN_DESTDIR}/home/${CN_USER_NAME}/.cinnamon/configs/menu@cinnamon.org/
116
117     # Copy panel-launchers@cinnamon.org.json to set launchers
118     PANEL_LAUNCHER="/usr/share/cnchi/scripts/postinstall/panel-launchers@cinnamon.org.json"
119     if [[ firefox = "${CN_BROWSER}" ]]; then
120         sed -i 's|chromium|firefox|g' ${PANEL_LAUNCHER}
121     elif [ "${CN_BROWSER}" == "" ]; then
122         sed -i 's|"chromium.desktop",||g' ${PANEL_LAUNCHER}
123     fi
124
125     mkdir -p ${CN_DESTDIR}/home/${CN_USER_NAME}/.cinnamon/configs/panel-launchers@cinnamon.org/
126     cp -f /usr/share/cnchi/scripts/postinstall/panel-launchers@cinnamon.org.json ${CN_DESTDIR}/home/${CN_USER_NAME}/.cinnamon/configs/panel-launchers@cinnamon.org/
127
128     set_dmrc cinnamon
129 }
130
131 xfce_settings() {
132     set_gsettings
133     set_xscreensaver
134
135     # Set XFCE settings
136     mkdir -p ${CN_DESTDIR}/home/${CN_USER_NAME}/.config/xfce4/xfconf/xfce-perchannel-xml
137     cp -R ${CN_DESTDIR}/etc/xdg/xfce4/panel ${CN_DESTDIR}/etc/xdg/xfce4/helpers.rc ${CN_DESTDIR}/home/${CN_USER_NAME}/.config/xfce4
138
139     HELPERS_RC="${CN_DESTDIR}/home/${CN_USER_NAME}/.config/xfce4/helpers.rc"
140     if [[ ${CN_BROWSER} = "chromium" ]]; then
141         sed -i "s/WebBrowser=firefox/WebBrowser=chromium/" ${HELPERS_RC}
142     elif [ "${CN_BROWSER}" == "" ]; then
143         sed -i "s/WebBrowser=firefox//" ${HELPERS_RC}
144     fi
145
146     set_dmrc xfce
147
148     # Add lxpolkit to autostart apps
149     cp /etc/xdg/autostart/lxpolkit.desktop ${CN_DESTDIR}/home/${CN_USER_NAME}/.config/autostart
150 }
151
152 openbox_settings() {
153     set_gsettings
154     set_xscreensaver
155
156     set_dmrc openbox
157
158     # Set Numix theme in oblogout
159     if [[ -f /etc/oblogout.conf ]]; then
160         sed -i 's|buttontheme = oxygen|buttontheme = Numix|g' "${CN_DESTDIR}/etc/oblogout.conf"
161     fi
162 }
163
164 kde_settings() {
165     set_gsettings
166     set_xscreensaver
167
168     set_dmrc kde-plasma
169
170     # Force QtCurve to use our theme
171     rm -R ${CN_DESTDIR}/usr/share/kstyle/themes/qtcurve.themerc
172
173     # Setup user defaults
174     #if [ -f "${CN_DESTDIR}/usr/share/antergos-kde-setup/install.sh" ]; then
175     #    chroot ${CN_DESTDIR} /usr/share/antergos-kde-setup/install.sh ${CN_USER_NAME}
176     #elif [ -f "${CN_DESTDIR}/usr/share/antergos-desktop" ]; then
177     #    chroot ${CN_DESTDIR} /usr/bin/antergos-desktop plasma ${CN_USER_NAME}
178     #fi
179
180     cp ${CN_DESTDIR}/etc/skel/.gtkrc-2.0-kde4 ${CN_DESTDIR}/root
181     chroot ${CN_DESTDIR} "ln -s /root/.gtkrc-2.0-kde4 /root/.gtkrc-2.0"
182
183     # Set default directories
184     chroot ${CN_DESTDIR} su -c xdg-user-dirs-update ${CN_USER_NAME}
185 }
186
187 mate_settings() {
188     set_gsettings
189     set_xscreensaver
190
191     set_dmrc mate
192
193     # Set MintMenu Favorites
194     APP_LIST="/usr/share/cnchi/scripts/postinstall/applications.list"
195     if [[ "${CN_BROWSER}" = 'firefox' ]]; then
196         sed -i 's|chromium|firefox|g' ${APP_LIST}
197     elif [ "${CN_BROWSER}" == "" ]; then
198         sed -i 's|location:/usr/share/applications/chromium.desktop||g' ${APP_LIST}
199     fi
200
201     cp ${APP_LIST} "${CN_DESTDIR}/usr/lib/linuxmint/mintMenu/applications.list"
202
203     # Work-around for bug in mate-panel
204     CN_POST_INSTALL_DIR=/usr/share/cnchi/scripts/postinstall
205     CN_HOTFIX_SCRIPT="${CN_POST_INSTALL_DIR}/first-boot-hotfix.sh"
206     CN_HOTFIX_DESKTOP="${CN_POST_INSTALL_DIR}/first-boot-hotfix.desktop"
207     cp "${CN_HOTFIX_SCRIPT}" "${CN_DESTDIR}/usr/bin"
208     mkdir -p "${CN_DESTDIR}/home/${CN_USER_NAME}/.config/autostart"
209     cp "${CN_HOTFIX_DESKTOP}" "${CN_DESTDIR}/home/${CN_USER_NAME}/.config/autostart"
210     chmod +x "${CN_DESTDIR}/usr/bin/first-boot-hotfix.sh"
211 }
212
213 nox_settings() {
214     echo "Done"
215 }
216
217 # Experimental DE's
218
219 lxqt_settings() {
220     set_gsettings
221     set_xscreensaver
222
223     set_dmrc razor
224 }
225
226 enlightenment_settings() {
227     set_gsettings
228     set_xscreensaver
229
230     # http://git.enlightenment.org/core/enlightenment.git/plain/data/tools/enlightenment_remote
231
232     # Setup user defaults
233     #chroot ${CN_DESTDIR} /usr/share/antergos-enlightenment-setup/install.sh ${CN_USER_NAME}
234     #chroot ${CN_DESTDIR} /usr/bin/antergos-desktop enlightenment ${CN_USER_NAME}
235
236     # Set Keyboard layout
237     E_CFG="/home/${CN_USER_NAME}/.e/e/config/standard/e.cfg"
238     E_SRC="/home/${CN_USER_NAME}/.e/e/config/standard/e.src"
239
240     ${CN_DESTDIR}/usr/bin/eet -d ${E_CFG} config ${E_SRC}
241     sed -i 's/"us"/"${CN_KEYBOARD_LAYOUT}"/' ${E_SRC}
242     if [[ "${CN_KEYBOARD_VARIANT}" != '' ]]; then
243         sed -i 's/"basic"/"${CN_KEYBOARD_VARIANT}"/' ${E_SRC}
244     fi
245     ${CN_DESTDIR}/usr/bin/eet -e ${E_CFG} config ${E_SRC} 1
246
247     set_dmrc enlightenment
248
249     echo "QT_STYLE_OVERRIDE=gtk" >> ${CN_DESTDIR}/etc/environment
250
251     # Add lxpolkit to autostart apps
252     cp /etc/xdg/autostart/lxpolkit.desktop ${CN_DESTDIR}/home/${CN_USER_NAME}/.config/autostart
253 }
254
255 budgie_settings() {
256     set_gsettings
257     set_xscreensaver
258
259     set_dmrc budgie
260 }
261
262 i3_settings() {
263     set_gsettings
264     set_xscreensaver
265
266     set_dmrc i3
267 }
268
269 postinstall() {
270     # Specific user configurations
271     if [[ -f /usr/share/applications/firefox.desktop ]]; then
272         export CN_BROWSER=firefox
273     elif [[ -f /usr/share/applications/chromium.desktop ]]; then
274         export CN_BROWSER=chromium
275     else
276         export CN_BROWSER=""
277     fi
278
279     # Workaround for LightDM bug https://bugs.launchpad.net/lightdm/+bug/1069218
280     sed -i 's|UserAccounts|UserList|g' "${CN_DESTDIR}/etc/lightdm/users.conf"
281
282     ## Unmute alsa channels
283     #chroot "${CN_DESTDIR}" amixer -c 0 -q set Master playback 50% unmute
284
285     # Configure touchpad. Skip with base installs
286     if [[ "base" != "${CN_DESKTOP}" ]]; then
287         set_xorg_touchpad
288     fi
289
290     # Fix ugly styles for Qt applications when running under GTK-based desktops and Qt 5.7+
291     if [[ kde != "${CN_DESKTOP}" && lxqt != "${CN_DESKTOP}" ]]; then
292         mkdir -p "${CN_DESTDIR}/home/${CN_USER_NAME}/.config/qt5ct" "${CN_DESTDIR}/etc/skel/qt5ct"
293         cp /usr/share/cnchi/scripts/postinstall/qt5ct.conf "${CN_DESTDIR}/etc/skel/qt5ct"
294         cp /usr/share/cnchi/scripts/postinstall/qt5ct.conf "${CN_DESTDIR}/home/${CN_USER_NAME}/.config/qt5ct"
295     fi
296
297     # Monkey patch session wrapper
298     cp /usr/share/cnchi/scripts/postinstall/Xsession "${CN_DESTDIR}/etc/lightdm"
299     chmod +x "${CN_DESTDIR}/etc/lightdm/Xsession"
300
301     # Configure fontconfig
302     FONTCONFIG_FILE="/usr/share/cnchi/scripts/fonts.conf"
303     if [[ -f "${FONTCONFIG_FILE}" ]]; then
304         FONTCONFIG_DIR="${CN_DESTDIR}/home/${CN_USER_NAME}/.config/fontconfig"
305         mkdir -p "${FONTCONFIG_DIR}"
306         cp "${FONTCONFIG_FILE}" "${FONTCONFIG_DIR}"
307     fi
308
309     # Set RebornOS name in filesystem files
310     cp /etc/arch-release "${CN_DESTDIR}/etc/"
311     cp /etc/os-release "${CN_DESTDIR}/etc/"
312     sed -i 's|Arch|RebornOS|g' "${CN_DESTDIR}/etc/issue"
313
314     # Set common desktop settigns
315     common_settings
316
317     # Set desktop-specific settings
318     ${CN_DESKTOP}_settings
319
320     # Set some environment vars
321     env_files=("${CN_DESTDIR}/etc/environment"
322         "${CN_DESTDIR}/home/${CN_USER_NAME}/.bashrc"
323         "${CN_DESTDIR}/etc/skel/.bashrc"
324     "${CN_DESTDIR}/etc/profile")
325
326     for file in "${env_files[@]}"
327     do
328         echo "# ---> Added by Cnchi RebornOS Installer Gnome based <---" >> "${file}"
329         if [ "${CN_BROWSER}" != "" ]; then
330             echo "BROWSER=/usr/bin/${CN_BROWSER}" >> "${file}"
331         fi
332         echo "EDITOR=/usr/bin/nano" >> "${file}"
333         echo "# ---> End added by Cnchi RebornOS Installer Gnome based <---" >> "${file}"
334     done
335
336     # Uncomplicated Firewall Workaround (Rafael from RebornOS)
337     cp /usr/share/cnchi/gufw.svg ${CN_DESTDIR}/usr/share/icons/default/gufw.svg
338     cp /usr/share/cnchi/gufw.png ${CN_DESTDIR}/usr/share/icons/hicolor/48x48/apps/gufw.png
339     cp /usr/share/cnchi/gufw.desktop ${CN_DESTDIR}/usr/share/applications/gufw.desktop
340
341     # Configure makepkg so that it doesn't compress packages after building.
342     # Most users are building packages to install them locally so there's no need for compression.
343     sed -i "s|^PKGEXT='.pkg.tar.xz'|PKGEXT='.pkg.tar'|g" "${CN_DESTDIR}/etc/makepkg.conf"
344
345     # Set lightdm-webkit2-greeter in lightdm.conf. This should have been done here (not in the pkg) all along.
346     if [[ deepin = "${CN_DESKTOP}" ]]; then
347         rm ${CN_DESTDIR}/etc/lightdm/lightdm.conf
348         cp /etc/lightdm/lightdm.conf ${CN_DESTDIR}/etc/lightdm/
349         # chroot ${CN_DESTDIR} sudo pacman -Rdd deepin-cosmic-reborn --noconfirm
350         # chroot ${CN_DESTDIR} sudo pacman -Rdd common-cosmic-reborn --noconfirm
351         # chroot ${CN_DESTDIR} sudo pacman -Rdd graphic-cosmic-reborn --noconfirm
352         # chroot ${CN_DESTDIR} sudo pacman -Rdd qt5ct --noconfirm --> Not installed now
353         cp /usr/share/cnchi/flatpak.sh ${CN_DESTDIR}/usr/bin/
354         cp /usr/share/cnchi/pkcon.sh ${CN_DESTDIR}/usr/bin/
355         cp /usr/share/cnchi/pkcon2.sh ${CN_DESTDIR}/usr/bin/
356         cp /usr/share/cnchi/flatpak.desktop ${CN_DESTDIR}/usr/share/applications/
357         cp /usr/share/cnchi/update.desktop ${CN_DESTDIR}/etc/xdg/autostart/
358         cp /usr/share/cnchi/updating.sh ${CN_DESTDIR}/usr/bin/
359         cp /usr/share/cnchi/deepin-fix.sh ${CN_DESTDIR}/usr/bin/
360         cp /usr/share/cnchi/deepin-fix.service ${CN_DESTDIR}/etc/systemd/system/
361         chroot ${CN_DESTDIR} sudo systemctl enable deepin-fix.service
362         chroot ${CN_DESTDIR} systemctl enable earlyoom
363         chroot ${CN_DESTDIR} systemctl enable ufw
364     fi
365
366     if [[ gnome = "${CN_DESKTOP}" ]]; then
367         chroot ${CN_DESTDIR} systemctl -fq enable gdm
368         # chroot ${CN_DESTDIR} sudo pacman -Rdd gnome-cosmic-reborn --noconfirm
369         # chroot ${CN_DESTDIR} sudo pacman -Rdd common-cosmic-reborn --noconfirm
370         # chroot ${CN_DESTDIR} sudo pacman -Rdd graphic-cosmic-reborn --noconfirm
371         cp /usr/share/cnchi/flatpak.sh ${CN_DESTDIR}/usr/bin/
372         cp /usr/share/cnchi/pkcon.sh ${CN_DESTDIR}/usr/bin/
373         cp /usr/share/cnchi/pkcon2.sh ${CN_DESTDIR}/usr/bin/
374         cp /usr/share/cnchi/flatpak.desktop ${CN_DESTDIR}/usr/share/applications/
375         cp /usr/share/cnchi/update.desktop ${CN_DESTDIR}/etc/xdg/autostart/
376         cp /usr/share/cnchi/updating.sh ${CN_DESTDIR}/usr/bin/
377         echo "# ---> Added by Cnchi RebornOS Installer Gnome based for Gnome Desktop <---" >> ${CN_DESTDIR}/etc/environment
378         echo "QT_QPA_PLATFORMTHEME=qt5ct" >> ${CN_DESTDIR}/etc/environment
379         echo "# ---> End added by Cnchi RebornOS Installer Gnome based for Gnome Desktop <---" >> ${CN_DESTDIR}/etc/environment
380         chroot ${CN_DESTDIR} systemctl enable earlyoom
381         chroot ${CN_DESTDIR} systemctl enable ufw
382     fi
383
384     if [[ apricity = "${CN_DESKTOP}" ]]; then
385         chroot ${CN_DESTDIR} systemctl -fq enable gdm
386         # chroot ${CN_DESTDIR} sudo pacman -Rdd gnome-cosmic-reborn --noconfirm
387         # chroot ${CN_DESTDIR} sudo pacman -Rdd common-cosmic-reborn --noconfirm
388         # chroot ${CN_DESTDIR} sudo pacman -Rdd graphic-cosmic-reborn --noconfirm
389         cp /usr/share/cnchi/flatpak.sh ${CN_DESTDIR}/usr/bin/
390         cp /usr/share/cnchi/pkcon.sh ${CN_DESTDIR}/usr/bin/
391         cp /usr/share/cnchi/pkcon2.sh ${CN_DESTDIR}/usr/bin/
392         cp /usr/share/cnchi/flatpak.desktop ${CN_DESTDIR}/usr/share/applications/
393         cp /usr/share/cnchi/update.desktop ${CN_DESTDIR}/etc/xdg/autostart/
394         cp /usr/share/cnchi/updating.sh ${CN_DESTDIR}/usr/bin/
395         echo "# ---> Added by Cnchi RebornOS Installer Gnome based for Apricity Desktop <---" >> ${CN_DESTDIR}/etc/environment
396         echo "QT_QPA_PLATFORMTHEME=qt5ct" >> ${CN_DESTDIR}/etc/environment
397         echo "# ---> End added by Cnchi RebornOS Installer Gnome based for Apricity Desktop <---" >> ${CN_DESTDIR}/etc/environment
398         chroot ${CN_DESTDIR} systemctl enable earlyoom
399         chroot ${CN_DESTDIR} systemctl enable ufw
400     fi
401
402     if [[ kde = "${CN_DESKTOP}" ]]; then
403         chroot ${CN_DESTDIR} systemctl -fq enable sddm
404         cp /usr/share/cnchi/sddm.conf ${CN_DESTDIR}/etc/
405         # chroot ${CN_DESTDIR} sudo pacman -Rdd kde-cosmic-reborn --noconfirm
406         # chroot ${CN_DESTDIR} sudo pacman -Rdd common-cosmic-reborn --noconfirm
407         # chroot ${CN_DESTDIR} sudo pacman -Rdd graphic-cosmic-reborn --noconfirm
408         cp /usr/share/cnchi/flatpak.sh ${CN_DESTDIR}/usr/bin/
409         cp /usr/share/cnchi/pkcon.sh ${CN_DESTDIR}/usr/bin/
410         cp /usr/share/cnchi/pkcon2.sh ${CN_DESTDIR}/usr/bin/
411         cp /usr/share/cnchi/flatpak.desktop ${CN_DESTDIR}/usr/share/applications/
412         cp /usr/share/cnchi/update.desktop ${CN_DESTDIR}/etc/xdg/autostart/
413         cp /usr/share/cnchi/updating.sh ${CN_DESTDIR}/usr/bin/
414         chroot ${CN_DESTDIR} systemctl enable earlyoom
415         chroot ${CN_DESTDIR} systemctl enable ufw
416     fi
417
418     if [[ budgie = "${CN_DESKTOP}" ]]; then
419         chroot ${CN_DESTDIR} systemctl -fq enable lightdm
420             sed -i 's/^webkit_theme\s*=\s*\(.*\)/webkit_theme = lightdm-webkit-theme-aether #\1/g' ${CN_DESTDIR}/etc/lightdm/lightdm-webkit2-greeter.conf
421             sed -i 's/^\(#?greeter\)-session\s*=\s*\(.*\)/greeter-session = lightdm-webkit2-greeter #\1/ #\2g' ${CN_DESTDIR}/etc/lightdm/lightdm.conf
422         # chroot ${CN_DESTDIR} sudo pacman -Rdd budgie-cosmic-reborn --noconfirm
423         # chroot ${CN_DESTDIR} sudo pacman -Rdd common-cosmic-reborn --noconfirm
424         # chroot ${CN_DESTDIR} sudo pacman -Rdd graphic-cosmic-reborn --noconfirm
425         cp /usr/share/cnchi/flatpak.sh ${CN_DESTDIR}/usr/bin/
426         cp /usr/share/cnchi/pkcon.sh ${CN_DESTDIR}/usr/bin/
427         cp /usr/share/cnchi/pkcon2.sh ${CN_DESTDIR}/usr/bin/
428         cp /usr/share/cnchi/flatpak.desktop ${CN_DESTDIR}/usr/share/applications/
429         cp /usr/share/cnchi/update.desktop ${CN_DESTDIR}/etc/xdg/autostart/
430         cp /usr/share/cnchi/updating.sh ${CN_DESTDIR}/usr/bin/
431         echo "# ---> Added by Cnchi RebornOS Installer Gnome based for Budgie Desktop <---" >> ${CN_DESTDIR}/etc/environment
432         echo "QT_QPA_PLATFORMTHEME=qt5ct" >> ${CN_DESTDIR}/etc/environment
433         echo "# ---> End added by Cnchi RebornOS Installer Gnome based for Budgie Desktop <---" >> ${CN_DESTDIR}/etc/environment
434         chroot ${CN_DESTDIR} systemctl enable earlyoom
435         chroot ${CN_DESTDIR} systemctl enable ufw
436     fi
437
438     if [[ i3 = "${CN_DESKTOP}" ]]; then
439         chroot ${CN_DESTDIR} systemctl -fq enable sddm
440         cp /usr/share/cnchi/sddm.conf ${CN_DESTDIR}/etc/
441         # chroot ${CN_DESTDIR} sudo pacman -Rdd i3-cosmic-reborn --noconfirm
442         # chroot ${CN_DESTDIR} sudo pacman -Rdd common-cosmic-reborn --noconfirm
443         # chroot ${CN_DESTDIR} sudo pacman -Rdd graphic-cosmic-reborn --noconfirm
444         cp /usr/share/cnchi/flatpak.sh ${CN_DESTDIR}/usr/bin/
445         cp /usr/share/cnchi/pkcon.sh ${CN_DESTDIR}/usr/bin/
446         cp /usr/share/cnchi/pkcon2.sh ${CN_DESTDIR}/usr/bin/
447         cp /usr/share/cnchi/flatpak.desktop ${CN_DESTDIR}/usr/share/applications/
448         cp /usr/share/cnchi/update.desktop ${CN_DESTDIR}/etc/xdg/autostart/
449         cp /usr/share/cnchi/updating.sh ${CN_DESTDIR}/usr/bin/
450         echo "# ---> Added by Cnchi RebornOS Installer Gnome based for i3 Desktop <---" >> ${CN_DESTDIR}/etc/environment
451         echo "QT_QPA_PLATFORMTHEME=qt5ct" >> ${CN_DESTDIR}/etc/environment
452         echo "# ---> End added by Cnchi RebornOS Installer Gnome based for i3 Desktop <---" >> ${CN_DESTDIR}/etc/environment
453         chroot ${CN_DESTDIR} systemctl enable earlyoom
454         chroot ${CN_DESTDIR} systemctl enable ufw
455     fi
456
457     if [ -f "${CN_DESTDIR}/usr/bin/enlightenment" ]; then
458         chroot ${CN_DESTDIR} systemctl -fq enable sddm
459         cp /usr/share/cnchi/sddm.conf ${CN_DESTDIR}/etc/
460         # chroot ${CN_DESTDIR} sudo pacman -Rdd enlightenment-cosmic-reborn --noconfirm
461         # chroot ${CN_DESTDIR} sudo pacman -Rdd common-cosmic-reborn --noconfirm
462         # chroot ${CN_DESTDIR} sudo pacman -Rdd graphic-cosmic-reborn --noconfirm
463         cp /usr/share/cnchi/flatpak.sh ${CN_DESTDIR}/usr/bin/
464         cp /usr/share/cnchi/pkcon.sh ${CN_DESTDIR}/usr/bin/
465         cp /usr/share/cnchi/pkcon2.sh ${CN_DESTDIR}/usr/bin/
466         cp /usr/share/cnchi/flatpak.desktop ${CN_DESTDIR}/usr/share/applications/
467         cp /usr/share/cnchi/update.desktop ${CN_DESTDIR}/etc/xdg/autostart/
468         cp /usr/share/cnchi/updating.sh ${CN_DESTDIR}/usr/bin/
469         echo "# ---> Added by Cnchi RebornOS Installer Gnome based for Enlightenment Desktop <---" >> ${CN_DESTDIR}/etc/environment
470         echo "QT_QPA_PLATFORMTHEME=qt5ct" >> ${CN_DESTDIR}/etc/environment
471         echo "# ---> End added by Cnchi RebornOS Installer Gnome based for Enlightenment Desktop <---" >> ${CN_DESTDIR}/etc/environment
472         chroot ${CN_DESTDIR} systemctl enable earlyoom
473         chroot ${CN_DESTDIR} systemctl enable ufw
474     fi
475
476     if [[ lxqt = "${CN_DESKTOP}" ]]; then
477         chroot ${CN_DESTDIR} systemctl -fq enable sddm
478         cp /usr/share/cnchi/sddm.conf ${CN_DESTDIR}/etc/
479         # chroot ${CN_DESTDIR} sudo pacman -Rdd lxqt-cosmic-reborn --noconfirm
480         # chroot ${CN_DESTDIR} sudo pacman -Rdd common-cosmic-reborn --noconfirm
481         # chroot ${CN_DESTDIR} sudo pacman -Rdd graphic-cosmic-reborn --noconfirm
482         cp /usr/share/cnchi/flatpak.sh ${CN_DESTDIR}/usr/bin/
483         cp /usr/share/cnchi/pkcon.sh ${CN_DESTDIR}/usr/bin/
484         cp /usr/share/cnchi/pkcon2.sh ${CN_DESTDIR}/usr/bin/
485         cp /usr/share/cnchi/flatpak.desktop ${CN_DESTDIR}/usr/share/applications/
486         cp /usr/share/cnchi/update.desktop ${CN_DESTDIR}/etc/xdg/autostart/
487         cp /usr/share/cnchi/updating.sh ${CN_DESTDIR}/usr/bin/
488         chroot ${CN_DESTDIR} systemctl enable earlyoom
489         chroot ${CN_DESTDIR} systemctl enable ufw
490     fi
491
492     if [ -f "${CN_DESTDIR}/usr/bin/lxsession" ]; then
493         rm ${CN_DESTDIR}/etc/lightdm/lightdm-webkit2-greeter.conf
494         cp /usr/share/cnchi/lightdm-webkit2-greeter.conf ${CN_DESTDIR}/etc/lightdm/
495         chmod go=rx ${CN_DESTDIR}/var/lib/lightdm-data
496         chroot ${CN_DESTDIR} systemctl -fq enable lxdm
497         # chroot ${CN_DESTDIR} sudo pacman -Rdd openbox-cosmic-reborn --noconfirm
498         # chroot ${CN_DESTDIR} sudo pacman -Rdd common-cosmic-reborn --noconfirm
499         # chroot ${CN_DESTDIR} sudo pacman -Rdd graphic-cosmic-reborn --noconfirm
500         cp /usr/share/cnchi/flatpak.sh ${CN_DESTDIR}/usr/bin/
501         cp /usr/share/cnchi/pkcon.sh ${CN_DESTDIR}/usr/bin/
502         cp /usr/share/cnchi/pkcon2.sh ${CN_DESTDIR}/usr/bin/
503         cp /usr/share/cnchi/flatpak.desktop ${CN_DESTDIR}/usr/share/applications/
504         cp /usr/share/cnchi/update.desktop ${CN_DESTDIR}/etc/xdg/autostart/
505         cp /usr/share/cnchi/conky-start.desktop ${CN_DESTDIR}/etc/xdg/autostart/
506         cp /usr/share/cnchi/updating.sh ${CN_DESTDIR}/usr/bin/
507         cp /usr/share/cnchi/tint2-start.desktop ${CN_DESTDIR}/etc/xdg/autostart/
508         cp /usr/share/cnchi/obmenu-gen.desktop ${CN_DESTDIR}/etc/xdg/autostart/
509         cp /usr/share/cnchi/openbox-config.sh ${CN_DESTDIR}/usr/bin/
510         chroot ${CN_DESTDIR} obmenu-generator -p -i
511         chroot ${CN_DESTDIR} systemctl enable earlyoom
512         chroot ${CN_DESTDIR} systemctl enable ufw
513     fi
514
515     if [[ mate = "${CN_DESKTOP}" ]]; then
516         chroot ${CN_DESTDIR} systemctl -fq enable sddm
517         cp /usr/share/cnchi/sddm.conf ${CN_DESTDIR}/etc/
518         # chroot ${CN_DESTDIR} sudo pacman -Rdd mate-cosmic-reborn --noconfirm
519         # chroot ${CN_DESTDIR} sudo pacman -Rdd common-cosmic-reborn --noconfirm
520         # chroot ${CN_DESTDIR} sudo pacman -Rdd graphic-cosmic-reborn --noconfirm
521         cp /usr/share/cnchi/flatpak.sh ${CN_DESTDIR}/usr/bin/
522         cp /usr/share/cnchi/pkcon.sh ${CN_DESTDIR}/usr/bin/
523         cp /usr/share/cnchi/pkcon2.sh ${CN_DESTDIR}/usr/bin/
524         cp /usr/share/cnchi/flatpak.desktop ${CN_DESTDIR}/usr/share/applications/
525         cp /usr/share/cnchi/update.desktop ${CN_DESTDIR}/etc/xdg/autostart/
526         cp /usr/share/cnchi/updating.sh ${CN_DESTDIR}/usr/bin/
527         chroot ${CN_DESTDIR} mate-panel --reset --layout default
528         # chroot ${CN_DESTDIR} mate-panel --reset --layout cinnamon
529         # chroot ${CN_DESTDIR} sudo mate-panel --reset --layout cinnamon
530         echo "# ---> Added by Cnchi RebornOS Installer Gnome based for MATE Desktop <---" >> ${CN_DESTDIR}/etc/environment
531         echo "QT_QPA_PLATFORMTHEME=qt5ct" >> ${CN_DESTDIR}/etc/environment
532         echo "# ---> End added by Cnchi RebornOS Installer Gnome based for MATE Desktop <---" >> ${CN_DESTDIR}/etc/environment
533         chroot ${CN_DESTDIR} systemctl enable earlyoom
534         chroot ${CN_DESTDIR} systemctl enable ufw
535     fi
536
537 if [[ xfce = "${CN_DESKTOP}" ]]; then
538         chroot ${CN_DESTDIR} systemctl -fq enable sddm
539         cp /usr/share/cnchi/sddm.conf ${CN_DESTDIR}/etc/
540         # chroot ${CN_DESTDIR} sudo pacman -Rdd xfce-cosmic-reborn --noconfirm
541         # chroot ${CN_DESTDIR} sudo pacman -Rdd common-cosmic-reborn --noconfirm
542         # chroot ${CN_DESTDIR} sudo pacman -Rdd graphic-cosmic-reborn --noconfirm
543         cp /usr/share/cnchi/flatpak.sh ${CN_DESTDIR}/usr/bin/
544         cp /usr/share/cnchi/pkcon.sh ${CN_DESTDIR}/usr/bin/
545         cp /usr/share/cnchi/pkcon2.sh ${CN_DESTDIR}/usr/bin/
546         cp /usr/share/cnchi/flatpak.desktop ${CN_DESTDIR}/usr/share/applications/
547         cp /usr/share/cnchi/update.desktop ${CN_DESTDIR}/etc/xdg/autostart/
548         cp /usr/share/cnchi/updating.sh ${CN_DESTDIR}/usr/bin/
549         echo "# ---> Added by Cnchi RebornOS Installer Gnome based for XFCE Desktop <---" >> ${CN_DESTDIR}/etc/environment
550         echo "QT_QPA_PLATFORMTHEME=qt5ct" >> ${CN_DESTDIR}/etc/environment
551         echo "# ---> End added by Cnchi RebornOS Installer Gnome based for XFCE Desktop <---" >> ${CN_DESTDIR}/etc/environment
552         chroot ${CN_DESTDIR} systemctl enable earlyoom
553         chroot ${CN_DESTDIR} systemctl enable ufw
554 fi
555
556 if [[ cinnamon = "${CN_DESKTOP}" ]]; then
557         chroot ${CN_DESTDIR} systemctl -fq enable sddm
558         cp /usr/share/cnchi/sddm.conf ${CN_DESTDIR}/etc/
559         # chroot ${CN_DESTDIR} sudo pacman -Rdd cinnamon-cosmic-reborn --noconfirm
560         # chroot ${CN_DESTDIR} sudo pacman -Rdd common-cosmic-reborn --noconfirm
561         # chroot ${CN_DESTDIR} sudo pacman -Rdd graphic-cosmic-reborn --noconfirm
562         cp /usr/share/cnchi/flatpak.sh ${CN_DESTDIR}/usr/bin/
563         cp /usr/share/cnchi/pkcon.sh ${CN_DESTDIR}/usr/bin/
564         cp /usr/share/cnchi/pkcon2.sh ${CN_DESTDIR}/usr/bin/
565         cp /usr/share/cnchi/flatpak.desktop ${CN_DESTDIR}/usr/share/applications/
566         cp /usr/share/cnchi/update.desktop ${CN_DESTDIR}/etc/xdg/autostart/
567         cp /usr/share/cnchi/updating.sh ${CN_DESTDIR}/usr/bin/
568         echo "# ---> Added by Cnchi RebornOS Installer Gnome based for Cinnamon Desktop <---" >> ${CN_DESTDIR}/etc/environment
569         echo "QT_QPA_PLATFORMTHEME=qt5ct" >> ${CN_DESTDIR}/etc/environment
570         echo "# ---> End added by Cnchi RebornOS Installer Gnome based for Cinnamon Desktop <---" >> ${CN_DESTDIR}/etc/environment
571         chroot ${CN_DESTDIR} systemctl enable earlyoom
572         chroot ${CN_DESTDIR} systemctl enable ufw
573 fi
574
575 if [[ pantheon = "${CN_DESKTOP}" ]]; then
576         chroot ${CN_DESTDIR} systemctl -fq enable sddm
577         cp /usr/share/cnchi/sddm.conf ${CN_DESTDIR}/etc/
578         # chroot ${CN_DESTDIR} sudo pacman -Rdd common-cosmic-reborn --noconfirm
579         # chroot ${CN_DESTDIR} sudo pacman -Rdd graphic-cosmic-reborn --noconfirm
580         # chroot ${CN_DESTDIR} sudo pacman -Rdd elementary-cosmic-reborn --noconfirm
581         cp /usr/share/cnchi/flatpak.sh ${CN_DESTDIR}/usr/bin/
582         cp /usr/share/cnchi/pkcon.sh ${CN_DESTDIR}/usr/bin/
583         cp /usr/share/cnchi/pkcon2.sh ${CN_DESTDIR}/usr/bin/
584         cp /usr/share/cnchi/flatpak.desktop ${CN_DESTDIR}/usr/share/applications/
585         cp /usr/share/cnchi/update.desktop ${CN_DESTDIR}/etc/xdg/autostart/
586         cp /usr/share/cnchi/updating.sh ${CN_DESTDIR}/usr/bin/
587         echo "# ---> Added by Cnchi RebornOS Installer Gnome based for Pantheon Desktop <---" >> ${CN_DESTDIR}/etc/environment
588         echo "QT_QPA_PLATFORMTHEME=qt5ct" >> ${CN_DESTDIR}/etc/environment
589         echo "# ---> End added by Cnchi RebornOS Installer Gnome based for Pantheon Desktop <---" >> ${CN_DESTDIR}/etc/environment
590         chroot ${CN_DESTDIR} systemctl enable earlyoom
591         chroot ${CN_DESTDIR} systemctl enable ufw
592 fi
593
594 if [[ windows = "${CN_DESKTOP}" ]]; then
595         chroot ${CN_DESTDIR} systemctl -fq enable sddm
596         cp /usr/share/cnchi/sddm.conf ${CN_DESTDIR}/etc/
597         # chroot ${CN_DESTDIR} sudo pacman -Rdd cinnamon-cosmic-reborn --noconfirm
598         # chroot ${CN_DESTDIR} sudo pacman -Rdd common-cosmic-reborn --noconfirm
599         # chroot ${CN_DESTDIR} sudo pacman -Rdd graphic-cosmic-reborn --noconfirm
600         cp /usr/share/cnchi/flatpak.sh ${CN_DESTDIR}/usr/bin/
601         cp /usr/share/cnchi/pkcon.sh ${CN_DESTDIR}/usr/bin/
602         cp /usr/share/cnchi/pkcon2.sh ${CN_DESTDIR}/usr/bin/
603         cp /usr/share/cnchi/flatpak.desktop ${CN_DESTDIR}/usr/share/applications/
604         cp /usr/share/cnchi/update.desktop ${CN_DESTDIR}/etc/xdg/autostart/
605         cp /usr/share/cnchi/updating.sh ${CN_DESTDIR}/usr/bin/
606         echo "# ---> Added by Cnchi RebornOS Installer Gnome based for Windows Desktop <---" >> ${CN_DESTDIR}/etc/environment
607         echo "QT_QPA_PLATFORMTHEME=qt5ct" >> ${CN_DESTDIR}/etc/environment
608         echo "# ---> End added by Cnchi RebornOS Installer Gnome based for Windows Desktop <---" >> ${CN_DESTDIR}/etc/environment
609         chroot ${CN_DESTDIR} systemctl enable earlyoom
610         chroot ${CN_DESTDIR} systemctl enable ufw
611 fi
612
613     # Copy pacman.conf file over
614     rm ${CN_DESTDIR}/etc/pacman.conf
615     cp /usr/share/cnchi/pacman.conf ${CN_DESTDIR}/etc/
616     cp /etc/pacman.d/reborn-mirrorlist ${CN_DESTDIR}/etc/pacman.d/
617
618     #Copy blacklist.conf file over
619     cp /etc/modprobe.d/blacklist.conf ${CN_DESTDIR}/etc/modprobe.d/
620
621     #Copy Plymouth Files over if the Plymouth feature has been selected
622     if [ -f "${CN_DESTDIR}/usr/bin/plymouth" ]; then
623     echo "[STATUS] Plymouth selected. Configuring now..." >${CN_DESTDIR}/var/log/cnchi/plymouth.log
624     echo "[STATUS] Plymouth selected. Configuring now..." >/tmp/cnchi.log
625     cp /usr/share/cnchi/plymouth.sh ${CN_DESTDIR}/usr/bin/
626     cp /usr/share/cnchi/plymouth-reborn.desktop ${CN_DESTDIR}/etc/xdg/autostart/
627     chroot ${CN_DESTDIR} plymouth-set-default-theme -R arch-charge-big
628     echo "[SUCCESS] Plymouth has been installed and configured" >${CN_DESTDIR}/var/log/cnchi/plymouth.log
629     echo "[SUCCESS] Plymouth has been installed and configured" >/tmp/cnchi.log
630     else
631     echo "[STATUS] Plymouth not selected" >${CN_DESTDIR}/var/log/cnchi/plymouth.log
632     echo "[STATUS] Plymouth not selected" >/tmp/postinstall.log
633     fi
634
635     # Ensure user permissions are set in /home
636     chroot "${CN_DESTDIR}" chown -R "${CN_USER_NAME}:users" "/home/${CN_USER_NAME}"
637
638     # Remove reborn user if it still exists
639     if [ -d "${CN_DESTDIR}/home/reborn" ]; then
640     chroot ${CN_DESTDIR} sudo rm -rf /home/reborn
641     fi
642     
643     # Remove rebornos user if it still exists
644     if [ -d "${CN_DESTDIR}/home/rebornos" ]; then
645     chroot ${CN_DESTDIR} sudo rm -rf /home/reborn
646     fi
647
648     # Start vbox client services if we are installed in vbox
649     if [[ ${CN_IS_VBOX} = "True" ]] || { [[ $(systemd-detect-virt) ]] && [[ 'oracle' = $(systemd-detect-virt -v) ]]; }; then
650         # TODO: This should be done differently
651         sed -i 's|echo "X|/usr/bin/VBoxClient-all \&\necho "X|g' "${CN_DESTDIR}/etc/lightdm/Xsession"
652     fi
653 }
654
655 touch /tmp/.postinstall.lock
656 echo "Called installation script with these parameters: [$1] [$2] [$3] [$4] [$5] [$6] [$7]" > /tmp/postinstall.log
657 CN_USER_NAME=$1
658 CN_DESTDIR=$2
659 CN_DESKTOP=$3
660 CN_LOCALE=$4
661 CN_IS_VBOX=$5
662 CN_KEYBOARD_LAYOUT=$6
663 CN_KEYBOARD_VARIANT=$7
664
665 # Use this to test this script (remember to mount /install manually before testing)
666 #chroot_setup "${CN_DESTDIR}"
667
668 { postinstall; } >> /tmp/postinstall.log 2>&1
669 rm /tmp/.postinstall.lock
670