OSDN Git Service

add youtube-dl and xclip
[instantos/instantOS.git] / install.sh
old mode 100644 (file)
new mode 100755 (executable)
index 14e8aef..c172e5b
-#!/usr/bin/env bash
+#!/bin/bash
+# central installer script for instantOS
 
-#############################################
-## installs all paperbenni suckless forks  ##
-## made for personal use, so be warned ;)  ##
-#############################################
+export PAPERSILENT="True"
 
-echo "installing paperbenni's suckless suite"
-
-source <(curl -s https://raw.githubusercontent.com/paperbenni/bash/master/import.sh)
-pb install
-
-# pinstall dash slop ffmpeg wmctrl
-
-gclone() {
-    git clone --depth=1 https://github.com/paperbenni/"$1".git
-}
-
-gprogram() {
-    wget "https://raw.githubusercontent.com/paperbenni/suckless/master/programs/$1"
-    usrbin "$1"
-}
-
-if [ "$1" = "dotfiles" ]; then
-    shift 1
-    DOTFILES="True"
+if [ $(whoami) = "root" ] || [ $(whoami) = "manjaro" ]; then
+    echo "user check successful"
+else
+    echo "please run this as root"
+    exit 1
 fi
 
-THEME="${1:-dracula}"
+RAW="https://raw.githubusercontent.com"
 
-rm -rf suckless
-mkdir suckless
-cd suckless
-
-gclone dwm
-gclone dmenu
-gclone st
-
-# needed for slock
-if grep -q 'nobody' </etc/groups; then
-    sudo groupadd nobody
+if cat /etc/os-release | grep -Eiq 'name.*(arch|manjaro|ubuntu)'; then
+    curl -s "$RAW/instantOS/instantLOGO/master/ascii.txt"
+    echo ""
+else
+    echo "distro not supported"
+    echo "supported are: Arch, Manjaro, Ubuntu"
+    exit
 fi
-gclone slock
-
-# session for lightdm
-wget https://raw.githubusercontent.com/paperbenni/suckless/master/dwm.desktop
-sudo mv dwm.desktop /usr/share/xsessions/
 
-# x session wrapper
-gprogram startdwm
-# shutdown popup that breaks restart loop
-gprogram sucklessshutdown
+REALUSERS="$(ls /home/ | grep -v '+')"
+export THEME=${1:-dracula}
 
-gprogram autoclicker
-# deadcenter toggle script
-gprogram deadcenter
+# run a tool as every existing
+# "real"(there's a human behind it) user
 
-# dmenu run but in terminal emulator st
-# only supported terminal apps (less to search through)
-gprogram dmenu_run_st
+userrun() {
+    rm -rf /tmp/instantinstall.sh &>/dev/null
+    curl -s "$1" >/tmp/instantinstall.sh
+    chmod 777 /tmp/instantinstall.sh
 
-gprogram dswitch
-gprogram dwork
-
-curl "$LINK/termprograms.txt" >~/.cache/termprograms.txt
-
-for FOLDER in ./*; do
-    if ! [ -d "$FOLDER" ]; then
-        echo "skipping $FOLDER"
-        continue
-    fi
-    pushd "$FOLDER"
-    if ! [ -e build.sh ]; then
-        rm config.h
-        make
-        sudo make install
+    if [ -n "$2" ] && getent passwd $2 && [ -e /home/$2 ]; then
+        echo "single user installation for $1"
+        sudo su "$2" -c /tmp/instantinstall.sh
     else
-        chmod +x ./build.sh
-        ./build.sh "$THEME"
-    fi
-    popd
-done
-
-# install dotfiles like bash,git and tmux config
-if [ -n "$DOTFILES" ]; then
-    curl https://raw.githubusercontent.com/paperbenni/dotfiles/master/install.sh | bash
-fi
-
-LINK="https://raw.githubusercontent.com/paperbenni/suckless/master"
-
-if cat /etc/os-release | grep -i 'arch'; then
-    pacinstall() {
-        for i in "$@"; do
-            { pacman -iQ "$i" || command -v "$i"; } &>/dev/null && continue
-            sudo pacman -S --noconfirm "$i"
-        done
-    }
-    echo "setting up arch specific stuff"
-
-    sudo pacman -Syu --noconfirm
-
-    # utilities
-    pacinstall picom
-
-    pacinstall bash dash
-    pacinstall wget slop
-
-    pacinstall ffmpeg
-
-    pacinstall dmidecode
-
-    pacinstall wmctrl
-    pacinstall xdotool
-    pacinstall xrandr
-
-    pacinstall ranger
-    pacinstall fzf
-
-    if ! command -v panther_launcher; then
-        wget "https://www.rastersoft.com/descargas/panther_launcher/panther_launcher-1.12.0-1-x86_64.pkg.tar.xz"
-        sudo pacman -U --noconfirm panther_launcher*.pkg.tar.xz
-        rm panther_launcher*.pkg.tar.xz
-    fi
-
-fi
-
-if sudo dmidecode --string chassis-type | grep -iq 'laptop'; then
-    touch .cache/islaptop
-fi
-
-# ubuntu specific stuff
-if grep -iq 'ubuntu' </etc/os-release; then
-
-    sudo apt-get update
-    sudo apt-get upgrade -y
-
-    # utilities
-    aptinstall compton
-
-    aptinstall bash dash
-
-    aptinstall wget slop
-
-    aptinstall ffmpeg
-
-    aptinstall xrandr
-
-    aptinstall fzf
-    aptinstall ranger
-
-    aptinstall() {
-        for i in "$@"; do
-            { dpkg -l "$i" || command -v "$i"; } &>/dev/null && continue
-            sudo apt-get install -y "$i"
+        for i in $REALUSERS; do
+            echo "processing user $i"
+            sudo su "$i" -c /tmp/instantinstall.sh
         done
-    }
-
-    if ! command -v panther_launcher; then
-        wget "https://www.rastersoft.com/descargas/panther_launcher/panther-launcher-xenial_1.12.0-ubuntu1_amd64.deb"
-        sudo dpkg -i panther-launcher*.deb
-        sudo apt-get install -fy
-        rm panther-launcher*.deb
     fi
-fi
-
-# auto start script with dwm
-ls ~/.dwm || mkdir ~/.dwm
-curl $LINK/autostart.sh >~/.dwm/autostart.sh
+    rm /tmp/instantinstall.sh
+}
 
-# set up multi monitor config for dswitch
-if ! [ -e ~/paperbenni/ismultimonitor ]; then
-    if xrandr | grep ' connected' | grep -Eo '[0-9]{3,}x' |
-        grep -o '[0-9]*' | wc -l | grep '2'; then
-        mkdir ~/paperbenni &>/dev/null
-        xrandr | grep ' connected' | grep -Eo '[0-9]{3,}x' |
-            grep -o '[0-9]*' >~/paperbenni/ismultimonitor
-        echo "$(wc -l ~/paperbenni/ismultimonitor) monitors detected"
+rootrun() {
+    if [[ "$1" =~ "/" ]]; then
+        RUNSCRIPT="$1"
     else
-        echo "not a multi monitor setup"
+        RUNSCRIPT="$RAW/instantos/instantos/master/$1"
     fi
-else
-    echo "monitor config: "
-    cat ~/paperbenni/ismultimonitor
-fi
-
-# notification program for deadd-center
-if ! command -v notify-send.py &>/dev/null; then
-    git clone --depth=2 https://github.com/phuhl/notify-send.py
-    cd notify-send.py
-    sudo pip2 install notify2
-    sudo python3 setup.py install
-    cd ..
-    sudo rm -rf notify-send.py
-fi
-
-mkdir -p ~/.config/deadd
-curl $LINK/deadd.conf >~/.config/deadd/deadd.conf
+    shift
+    curl -s "$RUNSCRIPT" | bash -s $@
+}
 
-# install win + a menus for shortcuts like screenshots and shutdown
-curl https://raw.githubusercontent.com/paperbenni/menus/master/install.sh | bash
+echo "installing dependencies"
+rootrun depend.sh
 
-## notification center ##
-# remove faulty installation
-sudo rm /usr/bin/deadd &>/dev/null
-sudo rm /usr/bin/deadcenter &>/dev/null
+echo "root: installing tools"
+rootrun rootinstall.sh "$1"
 
-# main binary
-echo "installing deadd"
-wget -q $LINK/bin/deadd.xz
-xz -d deadd.xz
-sleep 0.1
-sudo mv deadd /usr/bin/deadd
-sudo chmod +x /usr/bin/deadd
+userrun "$RAW/instantos/instantos/master/userinstall.sh"
 
-mkdir ~/paperbenni &>/dev/null
+echo "installing theme"
+userrun "$RAW/instantOS/instantTHEMES/master/$THEME.sh"
 
-# automatic wallpaper changer
-gclone rwallpaper
-cd rwallpaper
-mv rwallpaper.py ~/paperbenni/
-chmod +x wallpaper.sh
-mv wallpaper.sh ~/paperbenni/
-sudo pip3 install -r requirements.txt
-cd ..
-rm -rf rwallpaper
+echo "installing dotfiles"
+rootrun $RAW/paperbenni/dotfiles/master/rootinstall.sh
+userrun $RAW/paperbenni/dotfiles/master/userinstall.sh
 
-# install things like fonts or gtk theme
-if ! [ -e ~/.config/paperthemes/$THEME.txt ]; then
-    echo "installing theme"
-    curl -s "https://raw.githubusercontent.com/paperbenni/suckless/master/themes/$THEME.sh" | bash
-    mkdir ~/.config/paperthemes
-    touch ~/.config/paperthemes/$THEME.txt
-else
-    echo "theme installation already found"
-fi
-
-# fix java on dwm
-if ! grep 'dwm' </etc/profile; then
-    echo "fixing java windows for dwm in /etc/profile"
-    echo '# fix dwm java windows' | sudo tee -a /etc/profile
-    echo 'export _JAVA_AWT_WM_NONREPARENTING=1' | sudo tee -a /etc/profile
-else
-    echo "java workaround already applied"
-fi
+userrun "$RAW/instantos/instantos/master/userdepend.sh"