OSDN Git Service

fix mirrorlist generator
[instantos/instantARCH.git] / askutils.sh
index 1010879..e18d64c 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,9 +33,25 @@ 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 ')"
@@ -63,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
@@ -85,6 +107,7 @@ askregion() {
         done
     fi
 
+    iroot region "$REGION"
     [ -n "$CITY" ] && iroot city "$CITY"
 
 }
@@ -127,31 +150,33 @@ 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
+    MIRRORCODE="$({
+        echo 'auto detect mirrors (not recommended for speed)'
+        curl -s 'https://archlinux.org/mirrorlist/all/' | grep '##' | grep -iEv '(linux|arch|generated|filter)' |
+            grep -o '[^# ]*' | grep '.....'
+    } | imenu -l 'select mirror location')"
+
+    if grep -q 'auto detect' <<<"$MIRRORCODE"; then
+        iroot automirrors 1
+    else
+        iroot countrycode "$MIRRORCODE"
         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')"
 
         # validate input as a unix name
         if ! grep -Eq '^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$' <<<"$NEWUSER"; then
-            imenu -m "invalid username"
+            imenu -e "invalid username, usernames must not contain spaces or special symbols and start with a lowercase letter"
             unset NEWUSER
         fi
     done
@@ -216,6 +241,9 @@ until this is fixed" | imenu -M
         ;;
     virtualbox)
         iroot virtualbox 1
+        if imenu -c "would you like to install virtualbox guest additions?"; then
+            iroot guestadditions 1
+        fi
         ;;
     other)
         iroot othervm 1