OSDN Git Service

Merge branch 'master' of https://github.com/instantos/instantARCH
[instantos/instantARCH.git] / archinstall.sh
index 64081f7..3ec5c11 100755 (executable)
 #!/bin/bash
 
-# main script calling others
+###################################################
+## This is the official installer for instantOS  ##
+## instantOS is migrating from calamares to this ##
+###################################################
 
-# DO NOT USE, NOT READY YET
+# main script calling others
 
-# check for internet
-if ! ping -c 1 google.com &>/dev/null; then
-    echo "no internet"
+if ! whoami | grep -iq '^root'; then
+    echo "not running as root, switching"
+    curl -Lg git.io/instantarch | sudo bash
     exit
 fi
 
-# print logo
-curl -s 'https://raw.githubusercontent.com/instantOS/instantLOGO/master/ascii.txt'
+if [ -e /usr/share/liveutils ]; then
+    echo "preparing installation
+OK" | instantmenu -c -bw 4 -l 2 &
+else
+    # print logo
+    echo ""
+    echo ""
+    curl -s 'https://raw.githubusercontent.com/instantOS/instantLOGO/master/ascii.txt' | sed 's/^/    /g'
+    echo ""
+    echo ""
+fi
 
-echo "selecting fastest mirror"
-# sort mirrors
-pacman -Sy --noconfirm
-pacman -S reflector --noconfirm
-reflector --sort rate --save /etc/pacman.d/mirrorlist
+if ! command -v imenu; then
+    touch /tmp/removeimenu
+fi
+
+# download imenu
+curl -s https://raw.githubusercontent.com/instantOS/imenu/master/imenu.sh >/usr/bin/imenu
+chmod 755 /usr/bin/imenu
 
-# install dependencies
+while ! command -v imenu; do
+    echo "installing imenu"
+    curl -s https://raw.githubusercontent.com/instantOS/imenu/master/imenu.sh >/usr/bin/imenu
+    chmod 755 /usr/bin/imenu
+done
+
+setinfo() {
+    if [ -e /usr/share/liveutils ]; then
+        pkill instantmenu
+    fi
+    echo "$@" >/opt/instantprogress
+    echo "$@"
+}
+
+if command -v python; then
+    echo "import time; time.sleep(10009)" | python &
+    sleep 2
+    pkill python3
+fi
+
+# sort mirrors
 pacman -Sy --noconfirm
-pacman -S git --noconfirm
+pacman -S git --noconfirm --needed
 
 cd /root
+[ -e instantARCH ] && rm -rf instantARCH
 git clone --depth=1 https://github.com/instantos/instantARCH.git
 cd instantARCH
 
+# use alternative versions of the installer
+if [ -n "$1" ]; then
+    case "$1" in
+    "test")
+        echo "switching to testing branch"
+        git checkout -b testing
+        ;;
+    "manual")
+        if ! [ -e /root/manualarch ]; then
+            echo "no manual instantARCH version found. Please clone it to /root/manualarch"
+            sleep 5
+            echo "exiting"
+            exit
+        fi
+        rm -rf ./*
+        cp -r /root/manualarch/* .
+        ;;
+    *)
+        echo "running normal installer version"
+        ;;
+    esac
+
+fi
 chmod +x *.sh
-chmod +x **/*.sh
+chmod +x */*.sh
+
+./depend/depend.sh
+./artix/preinstall.sh
+
+cd /root/instantARCH
 
-rcd() {
-    cd /root/instantARCH
+./ask.sh || {
+    imenu -m "ask failed"
+    echo "ask failed" && exit
 }
 
-./depend/depend.sh
-rcd
-./lang/keyboard.sh
-rcd
-./init/init.sh
-rcd
-./disk/disk.sh
-rcd
-./pacstrap/pacstrap.sh
-# scripts executed in installed environment
-rcd
-./chrootscript depend/depend.sh
-rcd
-./chrootscript depend/system.sh
-rcd
-./chrootscript chroot/drivers.sh
+chmod +x *.sh
+chmod +x **/*.sh
+
+echo "local install"
+./localinstall.sh 2>&1 | tee /opt/localinstall &&
+    echo "system install" &&
+    ./systeminstall.sh 2>&1 | tee /opt/systeminstall
+
+pkill imenu
+pkill instantmenu
+sudo pkill imenu
+sudo pkill instantmenu
+sleep 2
+
+# ask to reboot, upload error data if install failed
+if ! [ -e /opt/installfailed ] || ! [ -e /opt/installsuccess ]; then
+    if command -v installapplet; then
+        notify-send "rebooting"
+        sleep 2
+        reboot
+    fi
+else
+
+    echo "installaion failed"
+    echo "uploading error data"
+
+    cat /opt/localinstall >/opt/install.log
+
+    if [ -e /opt/systeminstall ]; then
+        cat /opt/systeminstall >>/opt/install.log
+    fi
+
+    cd /opt
+    cp /root/instantARCH/data/netrc ~/.netrc
+    curl -n -F 'f:1=@install.log' ix.io
+    dialog --msgbox "installation failed
+please go to https://instantos.github.io/instantos.github.io/support
+for assistance or error reporting" 1000 1000
+
+fi
+
+if [ -e /tmp/removeimenu ]; then
+    rm /usr/bin/imenu
+fi
+
+echo "installation finished"