OSDN Git Service

add error reporting
[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     echo "preparing isntallation
18 OK" | instantmenu -c -bw 4 -l 2 &
19     sleep 1
20 else
21     # print logo
22     echo ""
23     echo ""
24     curl -s 'https://raw.githubusercontent.com/instantOS/instantLOGO/master/ascii.txt' | sed 's/^/    /g'
25     echo ""
26     echo ""
27 fi
28
29 if ! command -v imenu; then
30     touch /tmp/removeimenu
31 fi
32
33 # download imenu
34 curl -s https://raw.githubusercontent.com/instantOS/imenu/master/imenu.sh >/usr/bin/imenu
35 chmod 755 /usr/bin/imenu
36
37 while ! command -v imenu; do
38     echo "installing imenu"
39     curl -s https://raw.githubusercontent.com/instantOS/imenu/master/imenu.sh >/usr/bin/imenu
40     chmod 755 /usr/bin/imenu
41 done
42
43 setinfo() {
44     if [ -e /usr/share/liveutils ]; then
45         pkill instantmenu
46     fi
47     echo "$@" >/opt/instantprogress
48     echo "$@"
49 }
50
51 # sort mirrors
52 pacman -Sy --noconfirm
53 if command -v pacstrap; then
54     pacman -S reflector --noconfirm
55     echo "selecting fastest mirror"
56     reflector --latest 40 --protocol http --protocol https --sort rate --save /etc/pacman.d/mirrorlist
57 fi
58
59 # install dependencies
60 pacman -Sy --noconfirm
61 pacman -S git --noconfirm --needed
62
63 cd /root
64 [ -e instantARCH ] && rm -rf instantARCH
65 git clone --depth=1 https://github.com/instantos/instantARCH.git
66 cd instantARCH
67
68 ./depend/depend.sh
69 cd /root/instantARCH
70 ./ask.sh || {
71     echo "ask failed" && exit
72 }
73
74 chmod +x *.sh
75 chmod +x **/*.sh
76
77 echo "local install"
78 ./localinstall.sh &>/opt/localinstall &&
79     echo "system install" &&
80     ./systeminstall.sh &>/opt/systeminstall
81
82 # ask to reboot, upload error data if install failed
83 if ! [ -e /opt/installfailed ] || ! [ -e /opt/installsuccess ]; then
84     imenu -c "installation finished. reboot?" && touch /tmp/instantosreboot
85 else
86     echo "installaion failed"
87     echo "uploading error data"
88
89     cat /opt/localinstall >/opt/install.log
90
91     if [ -e /opt/systeminstall ]; then
92         cat /opt/systeminstall >>/opt/install.log
93     fi
94
95     cd /opt
96     cp /root/instantARCH/data/netrc ~/.netrc
97     curl -n -F 'f:1=@install.log' ix.io
98     dialog --msgbox "installation failed
99 please go to https://instantos.github.io/instantos.github.io/support
100 for assistance or error reporting" 1000 1000
101
102 fi
103
104 if [ -e /tmp/removeimenu ]; then
105     rm /usr/bin/imenu
106 fi
107
108 echo "installation finished"
109
110 sleep 2
111
112 [ -e /tmp/instantosreboot ] && reboot