OSDN Git Service

fix plymouth
[instantos/instantOS.git] / rootinstall.sh
1 #!/bin/bash
2
3 ######################################################
4 ## installs all system wide programs for instantOS  ##
5 ######################################################
6
7 if ! [ $(whoami) = "root" ]; then
8     echo "please run this as root"
9     exit 1
10 fi
11
12 mkdir -p /opt/instantos
13
14 # add group and add users to group
15 ugroup() {
16     groupadd "$1" &>/dev/null
17     for USER in $(ls /home/ | grep -v '+'); do
18         if ! sudo su "$USER" -c groups | grep -Eq " $1|$1 "; then
19             sudo gpasswd -a "$USER" "$1"
20         fi
21     done
22 }
23
24 ugroup video
25 ugroup input
26
27 RAW="https://raw.githubusercontent.com"
28
29 # adds permanent global environment variable
30 addenv() {
31     [ -e /etc/environment ] || touch /etc/environment
32     if [ "$1" = "-f" ]; then
33         local FORCE="true"
34         shift 1
35     fi
36
37     if grep -q "$1=" /etc/environment; then
38         if [ -z "$FORCE" ]; then
39             echo "key already existing"
40             return 1
41         else
42             sed -i "s~$1=.*~$1=$2~g" /etc/environment
43         fi
44     else
45         echo "$1=$2" >>/etc/environment
46     fi
47 }
48
49 addenv -f "QT_QPA_PLATFORMTHEME" "qt5ct"
50 addenv -f "PAGER" "less"
51 addenv -f "EDITOR" "$(which nvim)"
52 addenv -f "XDG_MENU_PREFIX" "gnome-"
53
54 # needed for instantLOCK
55 if grep -q 'nobody' </etc/groups &>/dev/null || grep -q 'nobody' </etc/group &>/dev/null; then
56     echo "nobody workaround not required"
57 else
58     sudo groupadd nobody
59 fi
60
61 # fix java gui appearing empty on instantWM
62 if ! grep -q 'instantwm' </etc/profile; then
63     echo "fixing java windows for instantwm in /etc/profile"
64     echo '# fix instantwm java windows' >>/etc/profile
65     echo 'export _JAVA_AWT_WM_NONREPARENTING=1' >>/etc/profile
66 else
67     echo "java workaround already applied"
68 fi
69
70 # color scheme for tty
71 if ! grep -q '# nord colors' /etc/profile; then
72     echo "applying color scheme"
73
74     echo '# nord colors' >>/etc/profile
75     echo 'if [ "$TERM" = "linux" ]; then' >>/etc/profile
76
77     cat <<EOT >>/etc/profile
78     echo -en "\e]P0383c4a" #black
79     echo -en "\e]P8404552" #darkgrey
80     echo -en "\e]P19A4138" #darkred
81     echo -en "\e]P9E7766B" #red
82     echo -en "\e]P24BEC90" #darkgreen
83     echo -en "\e]PA3CBF75" #green
84     echo -en "\e]P3CFCD63" #brown
85     echo -en "\e]PBFFD75F" #yellow
86     echo -en "\e]P45294e2" #darkblue
87     echo -en "\e]PC579CEF" #blue
88     echo -en "\e]P5CE50DD" #darkmagenta
89     echo -en "\e]PDE7766B" #magenta
90     echo -en "\e]P66BE5E7" #darkcyan
91     echo -en "\e]PE90FDFF" #cyan
92     echo -en "\e]P7CCCCCC" #lightgrey
93     echo -en "\e]PFFFFFFF" #white
94     clear #for background artifacting
95 fi
96
97 EOT
98
99 fi
100
101 # /tmp/topinstall is present if rootinstall is running on postinstall
102 # like on existing installations
103 if ! [ -e /tmp/topinstall ]; then
104     # install a custom repo
105     if ! grep -q '\[instant\]' /etc/pacman.conf; then
106         /usr/share/instantutils/repo.sh
107     else
108         echo "instantOS repo found"
109     fi
110
111     # deactivate root password, will be reenabled on postinstall
112     if ! grep -iq manjaro /etc/os-release; then
113         echo "root ALL=(ALL) NOPASSWD:ALL #instantosroot" >>/etc/sudoers
114         echo "" >>/etc/sudoers
115     fi
116
117     echo "installing boot splash screen"
118     plymouth-set-default-theme instantos
119
120     if ! grep -q 'instantos boot animation' /etc/default/grub; then
121         sed -i '/^GRUB_CMDLINE_LINUX_DEFAULT="/aGRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT quiet splash loglevel=3 rd.udev.log_priority=3 vt.global_cursor_default=0" # instantos boot animation' \
122             /etc/default/grub
123     fi
124
125     if ! grep -q '.*plymouth.* # boot screen' /etc/mkinitcpio.conf; then
126         sed -i '/^HOOKS/aHOOKS+=(plymouth) # boot screen' /etc/mkinitcpio.conf
127     fi
128
129     /etc/mkinitcpio.conf
130     update-grub
131     mkinitcpio -P
132
133     systemctl disable lightdm
134     systemctl enable lightdm-plymouth
135
136 fi
137
138 if [ -e /opt/livebuilder ]; then
139     echo "live session builder detected"
140 else
141     if [ -e /etc/lightdm/lightdm.conf ] && ! grep -q 'instantwm' /etc/lightdm/lightdm.conf; then
142         sudo sed -i 's/^user-session=.*/user-session=instantwm/g' /etc/lightdm/lightdm.conf
143         sudo sed -i '# user-session = Session to load for users/user-session=instantwm/g' /etc/lightdm/lightdm.conf
144     fi
145
146     # check if computer is a potato
147     MEMAMOUNT="$(free -m | grep -vi swap | grep -o '[0-9]*' | sort -n | tail -1)"
148
149     # computer is not a potato if it has an nvidia card, a ryzen processor or more than 3,5gb of ram.
150     # it can be unpotatoed at any time.
151
152     if grep -iq 'Ryzen' /proc/cpuinfo || lshw -C display | grep -q 'nvidia' || [ "$MEMAMOUNT" -gt 3500 ]; then
153         echo "classifying pc as not a potato"
154     else
155         echo "looks like your pc is a potato"
156         mkdir -p /opt/instantos
157         echo "true" >/opt/instantos/potato
158     fi
159
160     # fix brightness permissions
161     bash /opt/instantos/menus/data/backlight.sh
162     # set up postinstall trigger
163
164     mkdir -p /opt/instantos
165     touch /opt/instantos/installtrigger
166 fi
167
168 # indicator file
169 touch /opt/instantos/rootinstall