From 91cacfecec775d7b911d3b0abc09ca972117ee9a Mon Sep 17 00:00:00 2001 From: Luk Lu Date: Thu, 31 Mar 2022 14:13:03 +0800 Subject: [PATCH] u --- config-home.sh | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/config-home.sh b/config-home.sh index 427d35a..51148e1 100755 --- a/config-home.sh +++ b/config-home.sh @@ -30,11 +30,9 @@ else HomePath=~ fi -if [ ! -d $SourcePath ] +if [ -d $SourcePath ] && [ -d $HomePath ] then - echo "!!! Not existing $SourcePath, please try again" -else - echo "Linking $SourcePath/* to $HomePath/" + echo "--- Linking $SourcePath/* to $HomePath/* ..." pushd $HomePath homescriptlist=".emacs .emacs.lisp .bashrc .bash_profile .gitignore" for homescript in $homescriptlist @@ -44,22 +42,22 @@ else ln -s $SourcePath/$homescript $HomePath done popd - echo "Linked $SourcePath/* to $HomePath/" + if [ ! -d $HomePath/.ssh ] + then + echo "--- Creating $HomePath/.ssh ..." + mkdir $HomePath/.ssh + chmod 700 $HomePath/.ssh + fi + if [ -e $HomePath/.ssh/authorized_keys ] + then + echo "--- Removing $Homepath/.ssh/authorized_keys ..." + mv $Homepath/.ssh/authorized_keys $Homepath/.ssh/authorized_keys.backup + fi + echo "--- Linking $SourcePath/authorized_keys to $HomePath/.ssh/authorized_keys ..." + ln -s $SourcePath/authorized_keys $HomePath/.ssh/authorized_keys +else + echo "!!! Not existing $SourcePath or $HomePath, please try again." fi -if [ ! -d $HomePath/.ssh ] -then - echo "Creating $HomePath/.ssh" - mkdir $HomePath/.ssh - chmod 700 $HomePath/.ssh -fi -if [ -f $Homepath/.ssh/authorized_keys ] -then - echo "Removing $Homepath/.ssh/authorized_keys" - mv $Homepath/.ssh/authorized_keys $Homepath/.ssh/authorized_keys.backup -fi -ln -s $SourcePath/authorized_keys $HomePath/.ssh/authorized_keys -echo "Linked authorized_keys" - -echo "Applying $HomePath/.bashrc" +echo "--- Sourcing $HomePath/.bashrc ..." source $HomePath/.bashrc