OSDN Git Service

remove old file
[instantos/instantOS.git] / rootinstall.sh
index 42a9526..168d1b4 100755 (executable)
@@ -1,10 +1,10 @@
 #!/bin/bash
 
-######################################################
-## installs all system wide programs for instantOS  ##
-######################################################
+####################################################
+## installs all system wide tweaks for instantOS  ##
+####################################################
 
-if ! [ $(whoami) = "root" ]; then
+if ! [ "$(whoami)" = "root" ]; then
     echo "please run this as root"
     exit 1
 fi
@@ -49,6 +49,7 @@ addenv() {
 addenv -f "QT_QPA_PLATFORMTHEME" "qt5ct"
 addenv -f "PAGER" "less"
 addenv -f "EDITOR" "$(which nvim)"
+addenv -f "XDG_MENU_PREFIX" "gnome-"
 
 # needed for instantLOCK
 if grep -q 'nobody' </etc/groups &>/dev/null || grep -q 'nobody' </etc/group &>/dev/null; then
@@ -97,37 +98,80 @@ EOT
 
 fi
 
-if [ -e /etc/lightdm/lightdm.conf ] && ! grep -q 'instantwm' /etc/lightdm/lightdm.conf; then
-    sudo sed -i 's/^user-session=.*/user-session=instantwm/g' /etc/lightdm/lightdm.conf
-    sudo sed -i '# user-session = Session to load for users/user-session=instantwm/g' /etc/lightdm/lightdm.conf
-fi
+# /tmp/topinstall is present if rootinstall is running on postinstall
+# like on existing installations
+if ! [ -e /tmp/topinstall ] && command -v plymouth-set-default-theme && ! grep -iq 'manjaro' /etc/os-release; then
+    # install a custom repo
+    if ! grep -q '\[instant\]' /etc/pacman.conf; then
+        /usr/share/instantutils/repo.sh
+    else
+        echo "instantOS repo found"
+    fi
 
-rm -rf /tmp/instantinstall
-mkdir /tmp/instantinstall
-cd /tmp/instantinstall
+    # deactivate root password, will be reenabled on postinstall
+    if ! grep -iq manjaro /etc/os-release; then
+        echo "root ALL=(ALL) NOPASSWD:ALL #instantosroot" >>/etc/sudoers
+        echo "" >>/etc/sudoers
+    fi
 
-echo "the theme is $THEME"
+    if ! [ -e /opt/instantos/bootscreen ] && [ -e /opt/instantos/realinstall ] && ! [ -e /opt/instantos/noplymouth ]; then
+        echo "installing boot splash screen"
+        plymouth-set-default-theme instantos
 
-cd /tmp
-rm -rf instantos
+        if ! grep -q 'instantos boot animation' /etc/default/grub; then
+            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' \
+                /etc/default/grub
+        fi
 
-# check if computer is a potato
-MEMAMOUNT="$(free -m | grep -vi swap | grep -o '[0-9]*' | sort -n | tail -1)"
+        if ! grep -q '.*plymouth.* # boot screen' /etc/mkinitcpio.conf; then
+            sed -i '/^HOOKS/aHOOKS+=(plymouth) # boot screen' /etc/mkinitcpio.conf
+        fi
 
-if grep -iq 'Ryzen' /proc/cpuinfo || lshw -C display | grep -q 'nvidia' || [ "$MEMAMOUNT" -gt 3500 ]; then
-    echo "classifying pc as not a potato"
-else
-    echo "looks like your pc is a potato"
-    mkdir -p /opt/instantos
-    echo "true" >/opt/instantos/potato
+        systemctl disable lightdm
+        systemctl enable lightdm-plymouth
+
+        /etc/mkinitcpio.conf
+        update-grub
+        mkinitcpio -P
+        touch /opt/instantos/bootscreen
+    fi
 fi
 
-# install a custom repo
-if ! grep -q '\[instant\]' /etc/pacman.conf; then
-    /usr/share/instantutils/repo.sh
+# tmux doesn't count as console user
+if ! [ -e /etc/X11/Xwrapper.config ]; then
+    echo "enabling startx"
+    echo 'allowed_users=anybody' >/etc/X11/Xwrapper.config
+fi
+
+if [ -e /opt/livebuilder ]; then
+    echo "live session builder detected"
 else
-    echo "instantOS repo found"
+    if [ -e /etc/lightdm/lightdm.conf ] && ! grep -q 'instantwm' /etc/lightdm/lightdm.conf; then
+        sudo sed -i 's/^user-session=.*/user-session=instantwm/g' /etc/lightdm/lightdm.conf
+        sudo sed -i '# user-session = Session to load for users/user-session=instantwm/g' /etc/lightdm/lightdm.conf
+    fi
+
+    # check if computer is a potato
+    MEMAMOUNT="$($(which free) -m | grep -vi swap | grep -o '[0-9]*' | sort -n | tail -1)"
+
+    # computer is not a potato if it has an nvidia card, a ryzen processor or more than 3,5gb of ram.
+    # it can be unpotatoed at any time.
+
+    if grep -iq 'Ryzen' /proc/cpuinfo || lshw -C display | grep -q 'nvidia' || [ "$MEMAMOUNT" -gt 3500 ]; then
+        echo "classifying pc as not a potato"
+    else
+        echo "looks like your pc is a potato"
+        mkdir -p /opt/instantos
+        echo "true" >/opt/instantos/potato
+    fi
+
+    # fix brightness permissions
+    bash /usr/share/instantassist/data/backlight.sh
+    # set up postinstall trigger
+
+    mkdir -p /opt/instantos
+    touch /opt/instantos/installtrigger
 fi
 
-# fix brightness permissions
-bash /opt/instantos/menus/data/backlight.sh
+# indicator file
+touch /opt/instantos/rootinstall