From 0ddecd40c30ff03cb793c2791545445809b7dfd3 Mon Sep 17 00:00:00 2001 From: Luk Lu Date: Sat, 18 Jun 2022 10:49:55 +0800 Subject: [PATCH] u --- debian-add-user.sh | 14 +++++++++----- home-config.sh | 15 ++++++++++----- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/debian-add-user.sh b/debian-add-user.sh index 8d43257..a68b4d3 100755 --- a/debian-add-user.sh +++ b/debian-add-user.sh @@ -34,10 +34,14 @@ chmod a-w /etc/sudoers.d/${NewUser//./-} echo # 注意,在这里为新用户创建的配置文件,主人是 root,而不是新用户 -echo "<<< Configure $NewUser home with standard scripts? (注意,由 root 为新用户创建的配置文件的 owner 是 root,而不是新用户)" -read -p "y for yes, anything else for no >> " YesOrNo -if [ $YesOrNo = 'y' ] +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 /home/$NewUser --AdotMode +else + echo "<<< Configure $NewUser home with standard scripts? (注意,由 root 为新用户创建的配置文件的 owner 是 root,而不是新用户)" + read -p "y for yes, anything else for no >> " YesOrNo + if [ $YesOrNo = 'y' ] + then + source /faronear/fon/sysconfig/home-config.sh /faronear/fon/sysconfig/nixhome /home/$NewUser + fi fi - diff --git a/home-config.sh b/home-config.sh index aadcd5e..7a46281 100755 --- a/home-config.sh +++ b/home-config.sh @@ -5,7 +5,7 @@ then SourcePath=$1 else echo "Configure private home settings" - echo "Usage: setup.sh [Config-Source-Path] [User-Home-Path]" + echo "Usage: setup.sh [Config-Source-Path] [User-Home-Path] [--AdotMode]" read -p "Enter config source path (leave blank for [/Users/luk.lu]/faronear/fon/sysconfig/nixhome) >> " SourcePath if [ ! $SourcePath ] then @@ -37,13 +37,18 @@ then homescriptlist=".emacs .emacs.lisp .bashrc .bash_profile .gitignore" for homescript in $homescriptlist do - echo "--- Copying $SourcePath/$homescript to $HomePath/$homescript ..." rm -fr $homescript.backup mv $homescript $homescript.backup - cp -r $SourcePath/$homescript $HomePath + if [ $3 = '--AdotMode' ] # $3 通常不输入,所以默认是拷贝模式 + then + echo "--- Linking $SourcePath/$homescript to $HomePath/$homescript ..." + ln -s $SourcePath/$homescript $HomePath + else + echo "--- Copying $SourcePath/$homescript to $HomePath/$homescript ..." + cp -r $SourcePath/$homescript $HomePath + fi done - read -p "Linking .ssh/authorized_keys? Enter l to link or anything else to ignore >> " linkSshKeys - if [ $linkSshKeys == "l" ] + if [ $3 = '--AdotMode' ] # $3 通常不输入,所以默认是不给其他用户链接到 authorized_keys then echo "--- Linking $SourcePath/authorized_keys to $HomePath/.ssh/authorized_keys ..." mkdir -p $HomePath/.ssh