OSDN Git Service

add applets to live session
[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 command -v nvim &>/dev/null && addenv -f "EDITOR" "$(which nvim)"
52
53 # needed for instantLOCK
54 if grep -q 'nobody' </etc/groups || grep -q 'nobody' </etc/group; then
55     echo "nobody workaround not required"
56 else
57     sudo groupadd nobody
58 fi
59
60 # fix java gui appearing empty on instantWM
61 if ! grep -q 'instantwm' </etc/profile; then
62     echo "fixing java windows for instantwm in /etc/profile"
63     echo '# fix instantwm java windows' >>/etc/profile
64     echo 'export _JAVA_AWT_WM_NONREPARENTING=1' >>/etc/profile
65 else
66     echo "java workaround already applied"
67 fi
68
69 if [ -e /etc/lightdm/lightdm.conf ] && ! grep -q 'instantwm' /etc/lightdm/lightdm.conf; then
70     sudo sed -i 's/^user-session=.*/user-session=instantwm/g' /etc/lightdm/lightdm.conf
71     sudo sed -i '# user-session = Session to load for users/user-session=instantwm/g' /etc/lightdm/lightdm.conf
72 fi
73
74 rm -rf /tmp/instantinstall
75 mkdir /tmp/instantinstall
76 cd /tmp/instantinstall
77
78 echo "the theme is $THEME"
79
80 cd /tmp
81 rm -rf instantos