OSDN Git Service

add youtube-dl and xclip
[instantos/instantOS.git] / install.sh
index 554ab81..c172e5b 100755 (executable)
-#!/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
-pb git
-
-gprogram() {
-    wget "https://raw.githubusercontent.com/paperbenni/suckless/master/programs/$1"
-    usrbin -f "$1"
-}
-
-if [ "$1" = "dotfiles" ]; then
-    shift 1
-    DOTFILES="True"
-fi
-
-THEME="${1:-dracula}"
-echo "using theme $THEME"
-[ -e ~/paperbenni ] || mkdir ~/paperbenni
-echo "$THEME" >~/paperbenni/.theme
-
-rm -rf suckless
-mkdir suckless
-cd suckless
-
-gitclone dwm
-gitclone dmenu
-gitclone st
-
-# needed for slock
-if grep -q 'nobody' </etc/groups || grep -q 'nobody' </etc/group; then
-    echo "nobody workaround not required"
+if [ $(whoami) = "root" ] || [ $(whoami) = "manjaro" ]; then
+    echo "user check successful"
 else
-    sudo groupadd nobody
+    echo "please run this as root"
+    exit 1
 fi
 
-gitclone slock
+RAW="https://raw.githubusercontent.com"
 
-# install cursors for themes
-if ! [ -e ~/.icons/osx ]; then
-    curl -s https://raw.githubusercontent.com/paperbenni/cursors/master/install.sh | bash
+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
 
-# 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
-
-gprogram autoclicker
-# deadcenter toggle script
-gprogram deadcenter
-
-# dmenu run but in terminal emulator st
-# only supported terminal apps (less to search through)
-gprogram dmenu_run_st
-
-gprogram dswitch
-gprogram dworkl
-gprogram dworkr
+REALUSERS="$(ls /home/ | grep -v '+')"
+export THEME=${1:-dracula}
 
-# for that extra kick when doingg a typo
-gprogram sll
+# run a tool as every existing
+# "real"(there's a human behind it) user
 
-curl "$LINK/termprograms.txt" >~/.cache/termprograms.txt
+userrun() {
+    rm -rf /tmp/instantinstall.sh &>/dev/null
+    curl -s "$1" >/tmp/instantinstall.sh
+    chmod 777 /tmp/instantinstall.sh
 
-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 rofi
-
-    pacinstall bash dash tmux
-    pacinstall dialog
-    pacinstall wget slop
-    pacinstall acpi
-    pacinstall cpio
-
-    pacinstall ffmpeg
-    pacinstall feh
-    pacinstall mpv
-
-    pacinstall dmidecode
-
-    pacinstall wmctrl
-    pacinstall xdotool
-    pacinstall xrandr
-    pacinstall xorg-xsetroot
-
-    pacinstall conky
-    pacinstall ranger
-    pacinstall fzf
-    pacinstall sl
-
-    pacinstall xorg-fonts-misc
-    pacinstall lxappearance
-
-    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 ! [ ~/.local/share/fonts/symbola.ttf ]; then
-    mkdir -p ~/.local/share/fonts
-    cd ~/.local/share/fonts
-    wget "http://symbola.surge.sh/symbola.ttf"
-fi
-
-cd
-
-if acpi | grep -q '%'; 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
-
-    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
-    }
-
-    # utilities
-    aptinstall compton
-
-    aptinstall bash dash tmux
-    aptinstall dialog
-
-    aptinstall wget slop
-    aptinstall rofi
-    aptinstall acpi
-    aptinstall ffmpeg
-    aptinstall feh
-    aptinstall mpv
-    
-    aptinstall cpio
-
-    aptinstall xrandr
-    aptinstall x11-xserver-utils
-
-    aptinstall fzf
-    aptinstall ranger
-    aptinstall conky
-    aptinstall sl
-
-    aptinstall lxappearance
-
-    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
-chmod +x ~/.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
-    echo ""
-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
-
-# install wmutils
-if ! command -v pfw &>/dev/null; then
-    pushd /tmp
-    git clone --depth=1 https://github.com/wmutils/core.git
-    cd core
-    make
-    sudo make install
-    cd ..
-    popd
-fi
-
-# install win + a menus for shortcuts like screenshots and shutdown
-curl https://raw.githubusercontent.com/paperbenni/menus/master/install.sh | bash
-
-## notification center ##
-if ! command -v deadd; then
-    echo "installing deadd"
-    wget -q $LINK/bin/deadd.xz
-    xz -d deadd.xz
-    sleep 0.1
-    usrbin deadd
-fi
-
-if ! command -v dragon &>/dev/null; then
-    git clone --depth=1 https://github.com/mwh/dragon.git
-    cd dragon
-    make
-    make install
-    cd ..
-    rm -rf dragon
-fi
+    shift
+    curl -s "$RUNSCRIPT" | bash -s $@
+}
 
-if ! command -v lsw &>/dev/null; then
-    test -e core && (echo "core dir existing" && exit 1)
-    git clone --depth=1 https://github.com/wmutils/core.git
-    cd core
-    make
-    sudo make install
-    cd ..
-    rm -rf core
-fi
+echo "installing dependencies"
+rootrun depend.sh
 
-mkdir ~/paperbenni &>/dev/null
+echo "root: installing tools"
+rootrun rootinstall.sh "$1"
 
-# automatic wallpaper changer
-if [ "$2" = "rwall" ]; then
-    gitclone 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
-fi
+userrun "$RAW/instantos/instantos/master/userinstall.sh"
 
-fixtaptoclick() {
-    # fix tap to click behaviour
-    sudo mkdir -p /etc/X11/xorg.conf.d && sudo tee /etc/X11/xorg.conf.d/90-touchpad.conf <<'EOF' 1>/dev/null
-Section "InputClass"
-        Identifier "touchpad"
-        MatchIsTouchpad "on"
-        Driver "libinput"
-        Option "Tapping" "on"
-EndSection
+echo "installing theme"
+userrun "$RAW/instantOS/instantTHEMES/master/$THEME.sh"
 
-EOF
-}
+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"