Update setup.sh

This commit is contained in:
Frede H 2022-04-19 16:43:53 +02:00 committed by GitHub
parent e2a2100dbf
commit 3a849d1d6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,7 +1,23 @@
#!/bin/bash
pacman -S git
git clone https://github.com/fhdk/lxqt-kwin
cd lxqt-kwin
# https://stackoverflow.com/questions/38427000/bash-validating-user-name-with-regex
isValidUsername() {
local re='^[[:lower:]_][[:lower:][:digit:]_-]{2,15}$'
(( ${#1} > 16 )) && return 1
[[ $1 =~ $re ]] # return value of this comparison is used for the function
}
SCRIPTNAME=$(basename "$0")
VERSION="0.1"
if [[ -z "$1" ]]; then
echo "Required username is mussing."
echo "Add a lowercase username using ascii alpha digits only (no number digits) as first argument."
echo " e.g. ${SCRIPTNAME} fido"
exit 1
fi
if isValidUsername "$1"; then
pacman -Syu --needed - < $PWD/Packages-Desktop
systemctl enable NetworkManager
systemctl enable sddm
@ -9,3 +25,10 @@ systemctl enable firewalld
cp -r $PWD/etc/. /etc/
cp -r $PWD/usr/. /usr/
cp -r $PWD/root/. /root/
useradd -mUG lp,wheel,network,video $1
passwd $1
exit 0
else
echo "$1 is not a valid username"
exit 1
fi