OSDN Git Service

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