OSDN Git Service

e4636049a8235988b98779aab90a38ba88545a03
[instantos/instantOS.git] / install.sh
1 #!/bin/bash
2 # central installer script for instantOS
3
4 export PAPERSILENT="True"
5
6 if [ $(whoami) = "root" ] || [ $(whoami) = "manjaro" ]; then
7     echo "user check successful"
8 else
9     echo "please run this as root"
10     exit 1
11 fi
12
13 RAW="https://raw.githubusercontent.com"
14
15 if cat /etc/os-release | grep -Eiq 'name.*(arch|manjaro)'; then
16     curl -s "$RAW/instantOS/instantLOGO/master/ascii.txt"
17     echo ""
18 else
19     echo "distro not supported"
20     echo "supported are: Arch, Manjaro"
21     exit
22 fi
23
24 REALUSERS="$(ls /home/ | grep -v '+')"
25 export THEME=${1:-dracula}
26
27 # run a tool as every existing
28 # "real"(there's a human behind it) user
29
30 userrun() {
31     rm -rf /tmp/instantinstall.sh &>/dev/null
32     curl -s "$1" >/tmp/instantinstall.sh
33     chmod 777 /tmp/instantinstall.sh
34
35     if [ -n "$2" ] && getent passwd $2 && [ -e /home/$2 ]; then
36         echo "single user installation for $1"
37         sudo su "$2" -c /tmp/instantinstall.sh
38     else
39         for i in $REALUSERS; do
40             echo "processing user $i"
41             sudo su "$i" -c /tmp/instantinstall.sh
42         done
43     fi
44     rm /tmp/instantinstall.sh
45 }
46
47 rootrun() {
48     if [[ "$1" =~ "/" ]]; then
49         RUNSCRIPT="$1"
50     else
51         RUNSCRIPT="$RAW/instantos/instantos/master/$1"
52     fi
53     shift
54     curl -s "$RUNSCRIPT" | bash -s $@
55 }
56
57 echo "installing dependencies"
58 rootrun depend.sh
59
60 echo "root: installing tools"
61 rootrun rootinstall.sh "$1"
62
63 userrun "$RAW/instantos/instantos/master/userinstall.sh"
64
65 echo "installing theme"
66 userrun "$RAW/instantOS/instantTHEMES/master/$THEME.sh"
67
68 echo "installing dotfiles"
69 instantdotfiles root
70
71 # currently not needed
72 # userrun "$RAW/instantos/instantos/master/userdepend.sh"