From 96456b1f2b9d1c438e162506a74fd27a4ce07ee1 Mon Sep 17 00:00:00 2001 From: "luk.lu" Date: Thu, 4 Nov 2021 16:22:17 +0800 Subject: [PATCH] u --- config-debian.sh | 12 ++++----- config-home.sh | 63 +++++++++++++++--------------------------------- 2 files changed, 25 insertions(+), 50 deletions(-) diff --git a/config-debian.sh b/config-debian.sh index 38bb93a..93e520f 100755 --- a/config-debian.sh +++ b/config-debian.sh @@ -31,11 +31,8 @@ then git clone https://git.faronear.org/fon/sysconfig /faronear/fon/sysconfig fi -echo "<<< Configure home" -if [ ! -f "~/.bashrc.backup" ] -then - source /faronear/fon/sysconfig/config-home.sh /faronear/fon/sysconfig/home -fi +echo "<<< Configure root home" +source /faronear/fon/sysconfig/config-home.sh /faronear/fon/sysconfig/home echo "<<< Change root password" passwd @@ -46,7 +43,10 @@ passwd $NewUser mkdir /home/$NewUser chown $NewUser:$NewUser /home/$NewUser chmod 700 /home/$NewUser -# emacs /etc/passwd + +echo "<<< Configure $NewUser home" +source /faronear/fon/sysconfig/config-home.sh /faronear/fon/sysconfig/home /home/$NewUser + # Debian 10 default to /bin/sh sed -i "s|/home/$NewUser:/bin/sh$|/home/$NewUser:/bin/bash|g" /etc/passwd # Debian 9 default to empty diff --git a/config-home.sh b/config-home.sh index 1301b99..1096ec4 100755 --- a/config-home.sh +++ b/config-home.sh @@ -1,6 +1,6 @@ #!/bin/bash -echo "Usage: setup.sh [Source-Path-To-Config-Files]" +echo "Usage: setup.sh [Config-Source-Path] [User-Home-Path]" echo "---------------------------------------------" if [ $1 ] @@ -25,56 +25,31 @@ else fi fi +if [ $2 ] +then + HomePath=$2 +else + HomePath=~ +fi + if [ ! -d $SourcePath ] then echo "!!! Not existing $SourcePath, please try again" else echo "Copy home scripts from $SourcePath" - + pushd $HomePath echo "---------------------------------------------" - if [ -e ~/.emacs ] - then - mv ~/.emacs ~/.emacs.backup - fi - rm -fr ~/.emacs - ln -s $SourcePath/.emacs ~/ - echo Linked ~/.emacs to $SourcePath/.emacs - echo "---------------------------------------------" - if [ -e ~/.emacs.lisp ] - then - mv ~/.emacs.lisp ~/.emacs.lisp.backup - fi - rm -fr ~/.emacs.lisp - ln -s $SourcePath/.emacs.lisp ~/ - echo Linked ~/.emacs.lisp to $SourcePath/.emacs.lisp - - echo "---------------------------------------------" - if [ -e ~/.bashrc ] - then - mv ~/.bashrc ~/.bashrc.backup - fi - rm -fr ~/.bashrc - ln -s $SourcePath/.bashrc ~/ - echo Linked ~/.bashrc to $SourcePath/.bashrc - - echo "---------------------------------------------" - if [ -e ~/.bash_profile ] - then - mv ~/.bash_profile ~/.bash_profile.backup - fi - rm -fr ~/.bash_profile - ln -s $SourcePath/.bash_profile ~/ - echo Linked ~/.bash_profile to $SourcePath/.bash_profile - - echo "---------------------------------------------" - if [ -e ~/.gitignore ] - then - mv ~/.gitignore ~/.gitignore.backup - fi - rm -fr ~/.gitignore - ln -s $SourcePath/.gitignore ~/ - echo Linked ~/.gitignore to $SourcePath/.gitignore + for homescript in '.emacs .emacs.lisp .bashrc .bash_profile .gitignore' + do + if [ -f $homescript ] + then + mv $homescript $homescript.backup + fi + rm -fr $homescript + ln -s $SourcePath/$homescript $HomePath + echo Linked $HomePath/$homescript to $SourcePath/$homescript + done echo "---------------------------------------------" echo Executing ~/.bashrc