You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: installer.sh
+95-14Lines changed: 95 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,7 @@ USERPASSWORD_DONE=
37
37
USERNAME_DONE=
38
38
USERGROUPS_DONE=
39
39
USERACCOUNT_DONE=
40
+
SUPERUSER_DONE=
40
41
BOOTLOADER_DONE=
41
42
PARTITIONS_DONE=
42
43
NETWORK_DONE=
@@ -788,6 +789,69 @@ set_useraccount() {
788
789
chroot $TARGETDIR chpasswd -c SHA512
789
790
}
790
791
792
+
menu_superuser() {
793
+
local _preset
794
+
whiletrue;do
795
+
DIALOG --title "Select a superuser access tool (Optional). If ${RED}sudo${RESET} or ${RED}opendoas${RESET} are selected, the configured non-root user will be given access via the ${RED}wheel${RESET} group." \
796
+
--menu "$MENULABEL"${MENUSIZE} \
797
+
su "basic user switching tool (default, requires root password)" \
798
+
sudo "common and complex superuser tool" \
799
+
opendoas "superuser tool from OpenBSD"
800
+
if [ $?-eq 0 ];then
801
+
set_option SUPERUSER "$(cat $ANSWER)"
802
+
SUPERUSER_DONE=1
803
+
break
804
+
else
805
+
return
806
+
fi
807
+
done
808
+
}
809
+
810
+
validate_superuser() {
811
+
local ROOTPASSWORD="$(get_option ROOTPASSWORD)"
812
+
local SUPERUSER="$(get_option SUPERUSER)"
813
+
local USERLOGIN="$(get_option USERLOGIN)"
814
+
815
+
if [ "$SUPERUSER"= su ] && [ -z"$ROOTPASSWORD" ];then
816
+
return 1
817
+
fi
818
+
if [ "$SUPERUSER"!= su ] && [ -z"$USERLOGIN" ];then
819
+
return 2
820
+
fi
821
+
return 0
822
+
}
823
+
824
+
set_superuser() {
825
+
local SUPERUSER="$(get_option SUPERUSER)"
826
+
local USERLOGIN="$(get_option USERLOGIN)"
827
+
828
+
case"$SUPERUSER"in
829
+
su)
830
+
# nothing, this is part of util-linux and is installed by default
831
+
;;
832
+
sudo)
833
+
if [ -z"$(echo $(get_option USERGROUPS)| grep -w wheel)"-a-n"$USERLOGIN" ];then
834
+
# enable sudo for primary user USERLOGIN who is not member of wheel
835
+
echo"# Enable sudo for login '$USERLOGIN'">"$TARGETDIR/etc/sudoers.d/$USERLOGIN"
DIALOG --title "Installing base system packages..." \
1253
1322
--programbox 24 80
1254
1323
if [ $?-ne 0 ];then
@@ -1336,6 +1405,23 @@ with the root user in your new system.${RESET}\n\n
1336
1405
${BOLD}Do you want to continue?${RESET}" 10 60 ||return
1337
1406
fi
1338
1407
1408
+
# validate superuser configuration
1409
+
SUPERUSER_DONE="$(validate_superuser)"
1410
+
1411
+
case"$SUPERUSER_DONE"in
1412
+
1)
1413
+
DIALOG --yesno "${BOLD}Superuser access is not set up properly.${RESET}\n\n
1414
+
${BOLD}${RED}WARNING: The root password is not set and superuser access is configured to su. Superuser access will not be possible.${RESET}\n\n
1415
+
${BOLD}Do you want to continue?${RESET}" 10 60 ||return
1416
+
;;
1417
+
2)
1418
+
DIALOG --yesno "${BOLD}Superuser access is not set up properly.${RESET}\n\n
1419
+
${BOLD}${RED}WARNING: A non-root user account is not configured and superuser access is configured to sudo or opendoas. Superuser access will not be possible.${RESET}\n\n
1420
+
${BOLD}Do you want to continue?${RESET}" 10 60 ||return
1421
+
;;
1422
+
*) ;;
1423
+
esac
1424
+
1339
1425
DIALOG --yesno "${BOLD}The following operations will be executed:${RESET}\n\n
1340
1426
${BOLD}${TARGETFS}${RESET}\n
1341
1427
${BOLD}${RED}WARNING: data on partitions will be COMPLETELY DESTROYED for new \
@@ -1380,6 +1466,9 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return
1380
1466
if [ "$(get_option BOOTLOADER)"= none ];then
1381
1467
TO_REMOVE+=" grub-x86_64-efi grub-i386-efi grub"
1382
1468
fi
1469
+
if [ "$(get_option SUPERUSER)"!= sudo ];then
1470
+
TO_REMOVE+=" sudo"
1471
+
fi
1383
1472
# uninstall separately to minimise errors
1384
1473
forpkgin$TO_REMOVE;do
1385
1474
xbps-remove -r $TARGETDIR -Ry "$pkg">>$LOG2>&1
@@ -1439,18 +1528,7 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return
1439
1528
fi
1440
1529
fi
1441
1530
1442
-
if [ -d$TARGETDIR/etc/sudoers.d ];then
1443
-
USERLOGIN="$(get_option USERLOGIN)"
1444
-
if [ -z"$(echo $(get_option USERGROUPS)| grep -w wheel)"-a-n"$USERLOGIN" ];then
1445
-
# enable sudo for primary user USERLOGIN who is not member of wheel
1446
-
echo"# Enable sudo for login '$USERLOGIN'">"$TARGETDIR/etc/sudoers.d/$USERLOGIN"
0 commit comments