feat(testbed/cron): support nixos #69

Merged
DictXiong merged 3 commits from nixos into main 2024-05-29 22:44:41 +08:00
Showing only changes of commit 585b8ad82a - Show all commits

View File

@ -2,8 +2,14 @@
set -ex set -ex
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
check_username() {
( echo $1 | grep -qxE "^[a-z][-a-z0-9_]*\$" ) || return 1
return 0
}
touch_user() { touch_user() {
test -n "$1" test -n "$1"
check_username $1 || { echo "Invalid user name $1 !"; exit -1; }
if id -u $1 1>/dev/null 2>&1; then if id -u $1 1>/dev/null 2>&1; then
return return
fi fi
@ -12,13 +18,8 @@ touch_user() {
exit 1 exit 1
fi fi
adduser \ useradd -m --groups nasp $1
--shell /bin/bash \ su - $1 -c "true"
--disabled-password \
--home /home/$1 \
--gecos "nasp member" \
$1
usermod -a -G nasp $1
mkdir -p /home2/$1 mkdir -p /home2/$1
chown $1: /home2/$1 chown $1: /home2/$1