OSDN Git Service

add auto graphics driver installation
[instantos/instantOS.git] / rootinstall.sh
1 #!/bin/bash
2
3 ######################################################
4 ## installs all system wide programs for instantOS  ##
5 ######################################################
6 source <(curl -Ls https://git.io/JerLG)
7 pb install
8 pb git
9
10 if ! [ $(whoami) = "root" ]; then
11     echo "please run this as root"
12     exit 1
13 fi
14
15 mkdir -p /opt/instantos
16
17 # add group and add users to group
18 ugroup() {
19     groupadd "$1" &>/dev/null
20     for USER in $(ls /home/ | grep -v '+'); do
21         if ! sudo su "$USER" -c groups | grep -Eq " $1|$1 "; then
22             sudo gpasswd -a $USER $1
23         fi
24     done
25 }
26
27 ugroup video
28 ugroup input
29
30 RAW="https://raw.githubusercontent.com"
31
32 curl -s "$RAW/instantOS/instantASSIST/master/install.sh" | bash
33
34 # fallback wallpaper if others fail to load
35 if ! [ -e /opt/instantos/wallpapers/default.png ]; then
36     mkdir /opt/instantos/wallpapers
37     wget -qO /opt/instantos/wallpapers/default.png \
38         "$RAW/instantOS/instantLOGO/master/wallpaper/defaultwall.png"
39 fi
40
41 # adds permanent global environment variable
42 addenv() {
43     [ -e /etc/environment ] || touch /etc/environment
44     if [ "$1" = "-f" ]; then
45         local FORCE="true"
46         shift 1
47     fi
48
49     if grep -q "$1=" /etc/environment; then
50         if [ -z "$FORCE" ]; then
51             echo "key already existing"
52             return 1
53         else
54             sed -i "s~$1=.*~$1=$2~g" /etc/environment
55         fi
56     else
57         echo "$1=$2" >>/etc/environment
58     fi
59 }
60
61 addenv -f "QT_QPA_PLATFORMTHEME" "qt5ct"
62 addenv -f "PAGER" "less"
63 command -v nvim &>/dev/null && addenv -f "EDITOR" "$(which nvim)"
64
65 # needed for instantLOCK
66 if grep -q 'nobody' </etc/groups || grep -q 'nobody' </etc/group; then
67     echo "nobody workaround not required"
68 else
69     sudo groupadd nobody
70 fi
71
72 # fix java gui appearing empty on instantWM
73 if ! grep -q 'instantwm' </etc/profile; then
74     echo "fixing java windows for instantwm in /etc/profile"
75     echo '# fix instantwm java windows' >>/etc/profile
76     echo 'export _JAVA_AWT_WM_NONREPARENTING=1' >>/etc/profile
77 else
78     echo "java workaround already applied"
79 fi
80
81 if [ -e /etc/lightdm/lightdm.conf ] && ! grep -q 'instantwm' /etc/lightdm/lightdm.conf; then
82     sudo sed -i 's/^user-session=.*/user-session=instantwm/g' /etc/lightdm/lightdm.conf
83     sudo sed -i '# user-session = Session to load for users/user-session=instantwm/g' /etc/lightdm/lightdm.conf
84 fi
85
86 rm -rf /tmp/instantinstall
87 mkdir /tmp/instantinstall
88 cd /tmp/instantinstall
89
90 git clone --depth=1 https://github.com/instantOS/instantOS.git
91 cd instantOS
92 rm -rf .git
93
94 cd programs
95
96 for i in ./*; do
97     FILENAME=${i##*/}
98     echo "installing $FILENAME"
99     if ! [ -e "$i" ]; then
100         echo "error processing $i"
101         continue
102     fi
103     cat $i | sudo tee /usr/local/bin/$FILENAME &>/dev/null
104     sudo chmod 755 /usr/local/bin/"$FILENAME"
105 done
106
107 cd ..
108 # session for lightdm
109 sudo mv instantwm.desktop /usr/share/xsessions/
110 sudo chmod 644 /usr/share/xsessions/instantwm.desktop
111
112 rm -rf instantOS
113
114 # laptop specific stuff
115 if acpi | grep -q '[0-9]%' &>/dev/null; then
116     # fix tap to click not working with tiling wms
117     if ! [ -e /etc/X11/xorg.conf.d/90-touchpad.conf ] ||
118         ! cat /etc/X11/xorg.conf.d/90-touchpad.conf | grep -iq 'tapping.*"on"'; then
119
120         sudo mkdir -p /etc/X11/xorg.conf.d && sudo tee /etc/X11/xorg.conf.d/90-touchpad.conf <<'EOF' 1>/dev/null
121 Section "InputClass"
122         Identifier "touchpad"
123         MatchIsTouchpad "on"
124         Driver "libinput"
125         Option "Tapping" "on"
126 EndSection
127
128 EOF
129
130         # three and four finger swipes on laptop
131         if ! command -v libinput-gestures &>/dev/null; then
132             git clone --depth=1 https://github.com/bulletmark/libinput-gestures.git
133             cd libinput-gestures
134             sudo make install
135             cd ..
136             rm -rf libinput-gestures
137         fi
138     fi
139 else
140     echo "system is on a desktop"
141 fi
142
143 echo "the theme is $THEME"
144
145 iclone() {
146     echo "cloning $1"
147     gitclone instantOS/$1 &>/dev/null
148     if [ -e "$1"/build.sh ]; then
149         cd "$1"
150         ./build.sh "$THEME"
151         cd ..
152         rm -rf "$1"
153         cd /tmp/instantosbin
154     fi
155 }
156
157 rm -rf /tmp/instantosbin &>/dev/null
158 mkdir /tmp/instantosbin
159 cd /tmp/instantosbin
160
161 iclone instantWM
162 iclone instantMENU
163 iclone instantLOCK
164
165 cd /tmp
166 rm -rf instantos
167
168 mkdir -p /opt/instantos/scripts
169 cd /opt/instantos/scripts
170 curl -s "$RAW/instantOS/instantWALLPAPER/master/wall.sh" >wall.sh
171 curl -s "$RAW/instantOS/instantWALLPAPER/master/offlinewall.sh" >offlinewall.sh
172 curl -s "$RAW/instantOS/instantOS/master/monitor.sh" >monitor.sh
173 curl -s "$RAW/instantOS/instantOS/master/autostart.sh" >autostart.sh
174 chmod 755 *.sh