u
This commit is contained in:
parent
107b073f18
commit
7f15783d70
@ -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"
|
echo "=== Allow the new user $NewUser to sudo without password? <y> for yes, <<anything else>> for no"
|
||||||
read -p ">>> " AllowSudo
|
read -p ">>> " AllowSudo
|
||||||
if [ $AllowSudo ] && [ $AllowSudo == "y" ]
|
if [ "$AllowSudo" == "y" ]
|
||||||
then
|
then
|
||||||
#usermod -a -G sudo $NewUser # Add to sudo group # Option 1: add user to %sudo group
|
#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/
|
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,而不是新用户
|
# 注意,由 root 为新用户创建的配置文件的 owner 是 root,而不是新用户
|
||||||
if [ $NewUser = 'adot' ]
|
if [ $NewUser = 'adot' ]
|
||||||
then
|
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
|
else
|
||||||
echo "=== Configure $NewUser home with standard scripts? <y> for yes, <<anything else>> for no"
|
echo "=== Configure $NewUser home with standard scripts? <y> for yes, <<anything else>> for no"
|
||||||
read -p ">>> " ConfigHome
|
read -p ">>> " ConfigHome
|
||||||
if [ $ConfigHome ] && [ $ConfigHome = 'y' ]
|
if [ $ConfigHome ] && [ $ConfigHome = 'y' ]
|
||||||
then
|
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
|
else
|
||||||
echo "--- Nothing configured."
|
echo "--- Nothing configured."
|
||||||
fi
|
fi
|
||||||
|
@ -91,7 +91,7 @@ echo "=== Add a new user $NewUser"
|
|||||||
source /faronear/fon/sysconfig/debian-add-user.sh $NewUser
|
source /faronear/fon/sysconfig/debian-add-user.sh $NewUser
|
||||||
echo
|
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
|
read -p ">>> " XfceAutologinUsername
|
||||||
if [ $XfceAutologinUsername = $NewUser ]
|
if [ $XfceAutologinUsername = $NewUser ]
|
||||||
then
|
then
|
||||||
|
@ -10,7 +10,7 @@ popd
|
|||||||
|
|
||||||
mkdir fon
|
mkdir fon
|
||||||
pushd 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/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/yapi.faronear.org yapi.faronear.org.git
|
||||||
git clone https://git.faronear.org/fon/git.faronear.org git.faronear.org.git
|
git clone https://git.faronear.org/fon/git.faronear.org git.faronear.org.git
|
||||||
|
@ -34,7 +34,7 @@ fi
|
|||||||
|
|
||||||
if [ "$2" ]
|
if [ "$2" ]
|
||||||
then
|
then
|
||||||
HomePath=$2
|
HomePath=/home/$2
|
||||||
else
|
else
|
||||||
HomePath=~
|
HomePath=~
|
||||||
fi
|
fi
|
||||||
@ -48,14 +48,14 @@ then
|
|||||||
read -p ">>> " CopyOrLinkScripts
|
read -p ">>> " CopyOrLinkScripts
|
||||||
for homescript in $homescriptlist
|
for homescript in $homescriptlist
|
||||||
do
|
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' ]
|
if [ "$CopyOrLinkScripts" = 'l' ]
|
||||||
then
|
then
|
||||||
echo "--- Linking $SourcePath/$homescript to $HomePath/$homescript ..."
|
echo "--- Linking $SourcePath/$homescript to $HomePath/$homescript ..."
|
||||||
ln -s $SourcePath/$homescript $HomePath
|
ln -s $SourcePath/$homescript ./
|
||||||
else
|
else
|
||||||
echo "--- Copying $SourcePath/$homescript to $HomePath/$homescript ..."
|
echo "--- Copying $SourcePath/$homescript to $HomePath/$homescript ..."
|
||||||
cp -r $SourcePath/$homescript $HomePath
|
cp -r $SourcePath/$homescript ./
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo
|
echo
|
||||||
@ -66,12 +66,17 @@ then
|
|||||||
echo "--- Linking $SourcePath/authorized_keys to $HomePath/.ssh/authorized_keys ..."
|
echo "--- Linking $SourcePath/authorized_keys to $HomePath/.ssh/authorized_keys ..."
|
||||||
mkdir -p $HomePath/.ssh
|
mkdir -p $HomePath/.ssh
|
||||||
chmod 700 $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
|
ln -s $SourcePath/.ssh/authorized_keys $HomePath/.ssh/authorized_keys
|
||||||
elif [ "$CopyOrLinkOrOmitAuthorizedKeys" = 'a' ]
|
elif [ "$CopyOrLinkOrOmitAuthorizedKeys" = 'a' ]
|
||||||
then
|
then
|
||||||
mkdir -p $HomePath/.ssh
|
mkdir -p $HomePath/.ssh
|
||||||
chmod 700 $HomePath/.ssh
|
chmod 700 $HomePath/.ssh
|
||||||
|
if [ "$2" ]
|
||||||
|
then
|
||||||
|
chown $2:$2 $HomePath
|
||||||
|
fi
|
||||||
if [ -L '$HomePath/.ssh/authorized_keys' ]
|
if [ -L '$HomePath/.ssh/authorized_keys' ]
|
||||||
then
|
then
|
||||||
mv $HomePath/.ssh/authorized_keys $HomePath/.ssh/authorized_keys.backup
|
mv $HomePath/.ssh/authorized_keys $HomePath/.ssh/authorized_keys.backup
|
||||||
|
@ -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
|
Loading…
Reference in New Issue
Block a user