This commit is contained in:
陆柯 2022-11-15 13:11:10 +08:00
parent 107b073f18
commit 7f15783d70
5 changed files with 16 additions and 11 deletions

View File

@ -30,7 +30,7 @@ sed -i "s|/home/$NewUser:$|/home/$NewUser:/bin/bash|g" /etc/passwd
echo "=== Allow the new user $NewUser to sudo without password? <y> for yes, <<anything else>> for no"
read -p ">>> " AllowSudo
if [ $AllowSudo ] && [ $AllowSudo == "y" ]
if [ "$AllowSudo" == "y" ]
then
#usermod -a -G sudo $NewUser # Add to sudo group # Option 1: add user to %sudo group
echo "$NewUser ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers.d/${NewUser//./-} # Option 2: add a user file into /etc/sudoers.d/
@ -44,13 +44,13 @@ echo
# 注意,由 root 为新用户创建的配置文件的 owner 是 root而不是新用户
if [ $NewUser = 'adot' ]
then
source /faronear/fon/sysconfig/home-config.sh /faronear/fon/sysconfig/nixhome /home/$NewUser
source /faronear/fon/sysconfig/home-config.sh /faronear/fon/sysconfig/nixhome $NewUser
else
echo "=== Configure $NewUser home with standard scripts? <y> for yes, <<anything else>> for no"
read -p ">>> " ConfigHome
if [ $ConfigHome ] && [ $ConfigHome = 'y' ]
then
source /faronear/fon/sysconfig/home-config.sh /faronear/fon/sysconfig/nixhome /home/$NewUser
source /faronear/fon/sysconfig/home-config.sh /faronear/fon/sysconfig/nixhome $NewUser
else
echo "--- Nothing configured."
fi

View File

@ -91,7 +91,7 @@ echo "=== Add a new user $NewUser"
source /faronear/fon/sysconfig/debian-add-user.sh $NewUser
echo
echo "=== Enable xfce autologin [/etc/lightdm/lightdm.conf] as <$NewUser> for autologin or <<anything else>> for no change):"
echo "=== Enable xfce autologin [/etc/lightdm/lightdm.conf] as user <$NewUser> for autologin or <<anything else>> for no change):"
read -p ">>> " XfceAutologinUsername
if [ $XfceAutologinUsername = $NewUser ]
then

View File

@ -10,7 +10,7 @@ popd
mkdir fon
pushd fon
git clone https://git.faronear.org/npm/sysconfig sysconfig.git
git clone https://git.faronear.org/fon/sysconfig sysconfig.git
git clone https://git.faronear.org/fon/www.faronear.com www.faronear.com.git
git clone https://git.faronear.org/fon/yapi.faronear.org yapi.faronear.org.git
git clone https://git.faronear.org/fon/git.faronear.org git.faronear.org.git

View File

@ -34,7 +34,7 @@ fi
if [ "$2" ]
then
HomePath=$2
HomePath=/home/$2
else
HomePath=~
fi
@ -48,14 +48,14 @@ then
read -p ">>> " CopyOrLinkScripts
for homescript in $homescriptlist
do
mv $homescript $homescript.backup-[$(date +%Y%m%d-%H%M%S)]
mv $homescript $homescript.backup-$(date +%Y%m%d%H%M%S)
if [ "$CopyOrLinkScripts" = 'l' ]
then
echo "--- Linking $SourcePath/$homescript to $HomePath/$homescript ..."
ln -s $SourcePath/$homescript $HomePath
ln -s $SourcePath/$homescript ./
else
echo "--- Copying $SourcePath/$homescript to $HomePath/$homescript ..."
cp -r $SourcePath/$homescript $HomePath
cp -r $SourcePath/$homescript ./
fi
done
echo
@ -66,12 +66,17 @@ then
echo "--- Linking $SourcePath/authorized_keys to $HomePath/.ssh/authorized_keys ..."
mkdir -p $HomePath/.ssh
chmod 700 $HomePath/.ssh
mv $HomePath/.ssh/authorized_keys $HomePath/.ssh/authorized_keys.backup-[$(date +%Y%m%d-%H%M%S)]
chown adot:adot .ssh
mv $HomePath/.ssh/authorized_keys $HomePath/.ssh/authorized_keys.backup-$(date +%Y%m%d%H%M%S)
ln -s $SourcePath/.ssh/authorized_keys $HomePath/.ssh/authorized_keys
elif [ "$CopyOrLinkOrOmitAuthorizedKeys" = 'a' ]
then
mkdir -p $HomePath/.ssh
chmod 700 $HomePath/.ssh
if [ "$2" ]
then
chown $2:$2 $HomePath
fi
if [ -L '$HomePath/.ssh/authorized_keys' ]
then
mv $HomePath/.ssh/authorized_keys $HomePath/.ssh/authorized_keys.backup

View File

@ -1 +1 @@
curl -sSL https://git.faronear.org/npm/sysconfig/raw/branch/main/nixhome/.bashrc > ~/.bashrc
curl -sSL https://git.faronear.org/fon/sysconfig/raw/branch/main/nixhome/.bashrc > ~/.bashrc