OSDN Git Service

fix readme
[instantos/instantARCH.git] / archinstall.sh
1 #!/bin/bash
2
3 ###################################################
4 ## This is the official installer for instantOS  ##
5 ## instantOS is migrating from calamares to this ##
6 ###################################################
7
8 # main script calling others
9
10 if ! whoami | grep -iq '^root'; then
11     echo "not running as root, switching"
12     curl -Lg git.io/instantarch | sudo bash
13     exit
14 fi
15
16 if [ -e /usr/share/liveutils ]; then
17     pgrep instantmenu || echo "preparing installation
18 OK" | instantmenu -c -bw 4 -l 2 &
19 else
20     # print logo
21     echo ""
22     echo ""
23     curl -s 'https://raw.githubusercontent.com/instantOS/instantLOGO/master/ascii.txt' | sed 's/^/    /g'
24     echo ""
25     echo ""
26 fi
27
28 if ! command -v imenu; then
29     touch /tmp/removeimenu
30 fi
31
32 # download imenu
33 curl -s https://raw.githubusercontent.com/instantOS/imenu/master/imenu.sh >/usr/bin/imenu
34 chmod 755 /usr/bin/imenu
35
36 while ! command -v imenu; do
37     echo "installing imenu"
38     curl -s https://raw.githubusercontent.com/instantOS/imenu/master/imenu.sh >/usr/bin/imenu
39     chmod 755 /usr/bin/imenu
40 done
41
42 setinfo() {
43     if [ -e /usr/share/liveutils ]; then
44         pkill instantmenu
45     fi
46     echo "$@" >/opt/instantprogress
47     echo "$@"
48 }
49
50 if command -v python; then
51     echo "import time; time.sleep(10009)" | python &
52     sleep 2
53     pkill python3
54 fi
55
56 # sort mirrors
57 pacman -Sy --noconfirm
58 pacman -S git --noconfirm --needed
59
60 cd /root
61 [ -e instantARCH ] && rm -rf instantARCH
62 git clone --depth=1 https://github.com/instantos/instantARCH.git
63 cd instantARCH
64
65 # use alternative versions of the installer
66 if [ -n "$1" ]; then
67     case "$1" in
68     "test")
69         echo "switching to testing branch"
70         git checkout -b testing
71         ;;
72     "manual")
73         if ! [ -e /root/manualarch ]; then
74             echo "no manual instantARCH version found. Please clone it to /root/manualarch"
75             sleep 5
76             echo "exiting"
77             exit
78         fi
79         rm -rf ./*
80         cp -r /root/manualarch/* .
81         ;;
82     *)
83         echo "running normal installer version"
84         ;;
85     esac
86
87 fi
88 chmod +x *.sh
89 chmod +x */*.sh
90
91 ./depend/depend.sh
92 ./artix/preinstall.sh
93
94 [ -e /usr/share/liveutils ] && pkill instantmenu
95
96 cd /root/instantARCH
97
98 ./ask.sh || {
99     if ! [ -e /opt/instantos/installcanceled ]; then
100         imenu -m "ask failed"
101         echo "ask failed" && exit
102     else
103         rm /opt/instantos/installcanceled
104         pkill instantosinstall
105         exit
106     fi
107 }
108
109 chmod +x *.sh
110 chmod +x **/*.sh
111
112 echo "local install"
113 ./localinstall.sh 2>&1 | tee /opt/localinstall &&
114     echo "system install" &&
115     ./systeminstall.sh 2>&1 | tee /opt/systeminstall
116
117 pkill imenu
118 pkill instantmenu
119 sudo pkill imenu
120 sudo pkill instantmenu
121 sleep 2
122
123 uploadlogs() {
124     echo "uploading installation log"
125     cat /opt/localinstall >/opt/install.log
126
127     if [ -e /opt/systeminstall ]; then
128         cat /opt/systeminstall >>/opt/install.log
129     fi
130
131     cd /opt
132     cp /root/instantARCH/data/netrc ~/.netrc
133     curl -n -F 'f:1=@install.log' ix.io
134     dialog --msgbox "installation failed
135 please go to https://instantos.github.io/instantos.github.io/support
136 for assistance or error reporting" 1000 1000
137
138 }
139
140 # ask to reboot, upload error data if install failed
141 if ! [ -e /opt/installfailed ] || ! [ -e /opt/installsuccess ]; then
142     if command -v installapplet; then
143         notify-send "rebooting"
144         sleep 2
145         if iroot logging; then
146             uploadlogs
147             sleep 2
148         fi
149         reboot
150     fi
151 else
152     echo "installaion failed"
153     echo "uploading error data"
154     uploadlogs
155 fi
156
157 if [ -e /tmp/removeimenu ]; then
158     rm /usr/bin/imenu
159 fi
160
161 echo "installation finished"