OSDN Git Service

manual partitioning iroot
[instantos/instantARCH.git] / askutils.sh
index 7fe3881..b2bddc0 100755 (executable)
@@ -4,6 +4,12 @@
 # like topinstall.sh
 
 # check if the install session is GUI or cli
+
+if [ -z "$INSTANTARCH" ]; then
+    echo "defaulting instantarch location to /root/instantARCH"
+    INSTANTARCH="/root/instantARCH"
+fi
+
 guimode() {
     if [ -e /opt/noguimode ]; then
         return 1
@@ -27,25 +33,47 @@ wallstatus() {
     guimode && feh --bg-scale /usr/share/liveutils/$1.jpg &
 }
 
+artixinfo() {
+    if command -v systemctl; then
+        echo "regular arch/manjaro detected"
+        return
+    fi
+
+    echo "You appear to be installing the non-systemd version of instantOS.
+Support for non-systemd setups is experimental
+Any issues should be solvable with manual intervention
+Here's a list of things that do not work from the installer and how to work around them:
+disk editor: set up partitions beforehand or use automatic partitioning
+keyboard locale: set it manually after installation in the settings
+systemd-swap (obviously)" | imenu -M
+
+}
+
 # ask for keyboard layout
 asklayout() {
-    cd /root/instantARCH/data/lang/keyboard
+    cd "$INSTANTARCH"/data/lang/keyboard
     while [ -z "$NEWKEY" ]; do
         wallstatus worldmap
         NEWKEY="$(ls | imenu -l 'Select keyboard layout ')"
 
         # allow directly typing in layout name
         if [ "$NEWKEY" = "other" ]; then
-            OTHERKEY="$(localectl list-x11-keymap-layouts | imenu -l 'select keyboard layout ')"
-
-            if [ -z "$OTHERKEY" ]; then
-                unset NEWKEY
-            else
-                # newline is intentional!!!
-                echo "
+            if command -v localectl; then
+                OTHERKEY="$(localectl list-x11-keymap-layouts | imenu -l 'select keyboard layout ')"
+
+                if [ -z "$OTHERKEY" ]; then
+                    unset NEWKEY
+                else
+                    # newline is intentional!!!
+                    echo "
 $OTHERKEY" >/root/instantARCH/data/lang/keyboard/other
+                fi
+            else
+                imenu -m "not supported yet without systemd"
+                unset NEWKEY
             fi
         fi
+
     done
 
     # option to cancel the installer
@@ -57,7 +85,7 @@ $OTHERKEY" >/root/instantARCH/data/lang/keyboard/other
 
 # ask for default locale
 asklocale() {
-    cd /root/instantARCH/data/lang/locale
+    cd "$INSTANTARCH"/data/lang/locale
     while [ -z "$NEWLOCALE" ]; do
         NEWLOCALE="$(ls | imenu -l 'Select language> ')"
     done
@@ -79,6 +107,7 @@ askregion() {
         done
     fi
 
+    iroot region "$REGION"
     [ -n "$CITY" ] && iroot city "$CITY"
 
 }
@@ -118,9 +147,28 @@ This could prevent the system from booting" | imenu -C; then
 
 }
 
+# offer to choose mirror country
+askmirrors() {
+    iroot askmirrors 1
+    curl -s 'https://www.archlinux.org/mirrorlist/' | grep -i '<option value' >/tmp/mirrors.html
+    grep -v '>All<' /tmp/mirrors.html | sed 's/.*<option value=".*">\(.*\)<\/option>.*/\1/g' |
+        sed -e "1iauto detect mirrors (not recommended for speed)" |
+        imenu -l "choose mirror location" >/tmp/mirrorselect
+    if ! grep -q 'auto detect' </tmp/mirrorselect; then
+        cat /tmp/mirrors.html | grep ">$(cat /tmp/mirrorselect)<" | grep -o '".*"' | grep -o '[^"]*' | iroot i countrycode
+        if echo '> manually sorting mirrors may take a long time
+use arch ranking score (recommended)
+sort all mirrors by speed' | imenu -l 'choose mirror settings' | grep -q 'speed'; then
+            iroot sortmirrors 1
+        fi
+    else
+        iroot automirrors 1
+    fi
+}
+
 # ask for user details
 askuser() {
-    while [ -z $NEWUSER ]; do
+    while [ -z "$NEWUSER" ]; do
         wallstatus user
         NEWUSER="$(imenu -i 'set username')"
 
@@ -134,9 +182,71 @@ askuser() {
     while ! [ "$NEWPASS" = "$NEWPASS2" ] || [ -z "$NEWPASS" ]; do
         NEWPASS="$(imenu -P 'set password')"
         NEWPASS2="$(imenu -P 'confirm password')"
+        if ! [ "$NEWPASS" = "$NEWPASS2" ]; then
+            echo "the confirmation password doesn't match.
+Please enter a new password" | imenu -M
+        fi
     done
 
     iroot user "$NEWUSER"
     iroot password "$NEWPASS"
 
 }
+
+# ask about which hypervisor is used
+askvm() {
+    if imvirt | grep -iq 'physical'; then
+        echo "system does not appear to be a virtual machine"
+        return
+    fi
+
+    while [ -z "$VIRTCONFIRM" ]; do
+        if ! imenu -c "is this system a virtual machine?"; then
+            if echo "Are you sure it's not?
+giving the wrong answer here might greatly decrease performance. " | imenu -C; then
+                return
+            fi
+        else
+            VIRTCONFIRM="true"
+        fi
+    done
+    iroot isvm 1
+
+    echo "virtualbox
+kvm/qemu
+other" | imenu -l "which hypervisor is being used?" >/tmp/vmtype
+
+    HYPERVISOR="$(cat /tmp/vmtype)"
+    case "$HYPERVISOR" in
+    kvm*)
+        if grep 'vendor' /proc/cpuinfo | grep -iq 'AMD'; then
+            echo "WARNING:
+        kvm/QEMU on AMD is not meant for desktop use and
+        is lacking some graphics features.
+        This installation will work, but some features will have to be disabled and
+        others might not perform well. 
+        It is highly recommended to use Virtualbox instead." | imenu -M
+            iroot kvm 1
+            if lshw -c video | grep -iq 'qxl'; then
+                echo "WARNING:
+QXL graphics detected
+These may trigger a severe Xorg memory leak on kvm/QEMU on AMD,
+leading to degraded video and input performance,
+please switch your video card to either virtio or passthrough
+until this is fixed" | imenu -M
+            fi
+        fi
+        ;;
+    virtualbox)
+        iroot virtualbox 1
+        if imenu -c "would you like to install virtualbox guest additions?"; then
+            iroot guestadditions 1
+        fi
+        ;;
+    other)
+        iroot othervm 1
+        echo "selecting other"
+        ;;
+    esac
+
+}