This commit is contained in:
陆柯 2022-11-18 16:32:34 +08:00
parent 47f6ace177
commit 77e27d795f
2 changed files with 31 additions and 43 deletions

View File

@ -2,7 +2,7 @@
echo "Usage: this.sh [NewUser]"
echo "Example: this.sh alice"
echo "curl https://git.faronear.org/fon/sysconfig/raw/branch/main/debian-config.sh | sudo bash"
echo "curl https://git.faronear.org/fon/sysconfig/raw/branch/main/debian-config.sh > ~/debian-config.sh && sudo bash ~/debian-config.sh"
if [ v$1 != v ]
then
@ -16,18 +16,8 @@ apt update
apt install -y emacs git curl screen sudo automake rsync
echo
echo "=== Making dir /faronear"
if [ ! -d "/faronear" ]
then
mkdir /faronear
fi
echo
echo "=== Making dir /faronear/fon"
if [ ! -d "/faronear/fon" ]
then
mkdir /faronear/fon
fi
mkdir -p /faronear/fon
echo
echo "=== Git cloning to /faronear/fon/sysconfig"
@ -39,7 +29,7 @@ fi
echo
echo "=== Configure root home"
source /faronear/fon/sysconfig/home-config.sh /faronear/fon/sysconfig/nixhome
source /faronear/fon/sysconfig/home-config.sh /faronear/fon/sysconfig/nixhome root
echo
echo "=== Change root password? <y> for yes, <anything else> for omit:"

View File

@ -31,12 +31,15 @@ else
fi
fi
# $2 应当为用户名。为空则默认是 root
if [ "$2" ]
# $2 应当为用户名
if [ "$2" == 'root' ]
then
HomePath=/root
elif [ "$2" ]
then
HomePath=/home/$2
else
HomePath=/root
HomePath=~
fi
if [ -d "$HomePath" ]
@ -63,9 +66,6 @@ then
done
echo
if [ $2 ] # 如果 $2 不存在,则默认为是 root 用户,不需要设置 .ssh
then
mkdir -p $HomePath/.ssh
chmod 700 $HomePath/.ssh
# 注意,由 root 为新用户创建的配置文件的 owner 是 root而不是新用户导致新用户无法读取该文件而密钥登录失败因此要重设 owner。
@ -90,8 +90,6 @@ then
fi
echo
fi
popd
else
echo "!!! Not existing $HomePath, please try again."