Skip to content

Commit f688f0c

Browse files
committed
even more + ,,
1 parent 9618128 commit f688f0c

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

core/tabs/system-setup/arch/server-setup.sh

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ userinfo () {
242242
while true
243243
do
244244
read -r -p "Please enter username: " username
245-
if [[ "${username,,}" =~ ^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$ ]]
245+
if echo "$username" | grep -qE '^[a-z_][a-z0-9_-]{0,31}(\$)?$'
246246
then
247247
break
248248
fi
@@ -267,20 +267,23 @@ userinfo () {
267267
# Loop through user input until the user gives a valid hostname, but allow the user to force save
268268
while true
269269
do
270-
read -r -p "Please name your machine: " name_of_machine
271-
# hostname regex (!!couldn't find spec for computer name!!)
272-
if [[ "${name_of_machine,,}" =~ ^[a-z][a-z0-9_.-]{0,62}[a-z0-9]$ ]]
270+
printf "%b" "Please name your machine: "
271+
read -r machine_name
272+
273+
lower_machine_name=$(echo "$machine_name" | tr '[:upper:]' '[:lower:]')
274+
if echo "$lower_machine_name" | grep -q '^[a-z][a-z0-9_.-]\{0,62\}[a-z0-9]$'
273275
then
274276
break
275277
fi
276278
# if validation fails allow the user to force saving of the hostname
277-
read -r -p "Hostname doesn't seem correct. Do you still want to save it? (y/n)" force
278-
if [[ "${force,,}" = "y" ]]
279+
printf "%b" "Hostname doesn't seem correct. Do you still want to save it? (y/N) "
280+
read -r force
281+
if [[ "$force" == "y" || "$force" == "Y" ]]
279282
then
280283
break
281284
fi
282285
done
283-
export NAME_OF_MACHINE=$name_of_machine
286+
export NAME_OF_MACHINE=$lower_machine_name
284287
}
285288

286289
# Starting functions
@@ -376,7 +379,7 @@ subvolumesetup () {
376379
mountallsubvol
377380
}
378381

379-
if [[ "${DISK}" =~ "nvme" ]]; then
382+
if echo "$DISK" | grep -q "nvme"; then
380383
partition2=${DISK}p2
381384
partition3=${DISK}p3
382385
else
@@ -670,4 +673,4 @@ sed -i 's/^%wheel ALL=(ALL:ALL) NOPASSWD: ALL/# %wheel ALL=(ALL:ALL) NOPASSWD: A
670673
# Add sudo rights
671674
sed -i 's/^# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/' /etc/sudoers
672675
sed -i 's/^# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/' /etc/sudoers
673-
EOF
676+
EOF

0 commit comments

Comments
 (0)