OSDN Git Service

aa6ff2221e4815451c6ba6c0151f2e770627ec83
[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:-arc}
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 usercmd() {
48     REALUSERS="$(ls /home/ | grep -v '+')"
49     for i in $REALUSERS; do
50         echo "processing user $i"
51         sudo su "$i" -c "$1"
52     done
53 }
54
55 rootrun() {
56     if [[ "$1" =~ "/" ]]; then
57         RUNSCRIPT="$1"
58     else
59         RUNSCRIPT="$RAW/instantos/instantos/master/$1"
60     fi
61     shift
62     curl -s "$RUNSCRIPT" | bash -s $@
63 }
64
65 echo "installing dependencies"
66 rootrun depend.sh
67
68 echo "root: installing tools"
69 rootrun rootinstall.sh "$1"
70
71 userrun "$RAW/instantos/instantos/master/userinstall.sh"
72
73 instantthemes f
74
75 echo "installing dotfiles"
76 instantdotfiles root