From 30660d51d9b7578b3541b2cf7937871dc1709765 Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Sun, 5 Nov 2017 17:17:05 +0100 Subject: [PATCH] also use .profile when linking --- initialize_script | 4 ++-- scripts/create_container | 44 +++++++++++----------------------------- 2 files changed, 14 insertions(+), 34 deletions(-) diff --git a/initialize_script b/initialize_script index e8cb0ef..bf6771c 100755 --- a/initialize_script +++ b/initialize_script @@ -18,7 +18,7 @@ function user_config { mv $HOME/.bashrc $HOME/.bashrc.old echo "Old .bashrc moved to .bashrc.old" fi - ln -s $SCRIPTPATH/{.bashrc,vim/.vimrc,tmux/.tmux.conf} $HOME/; + ln -s $SCRIPTPATH/{.bashrc,vim/.vimrc,tmux/.tmux.conf,.profile} $HOME/; ln -s $SCRIPTPATH/vim/colors $HOME/.vim/ echo 'Linking configuration files done' elif [[ "$USER" == "root" ]]; then @@ -28,7 +28,7 @@ function user_config { mv /root/.bashrc /root/.bashrc.old echo "Old .bashrc moved to .bashrc.old" fi - ln -s $SCRIPTPATH/{.bashrc,vim/.vimrc,tmux/.tmux.conf} /root/ + ln -s $SCRIPTPATH/{.bashrc,vim/.vimrc,tmux/.tmux.conf,.profile} /root/ ln -s $SCRIPTPATH/vim/colors /root/.vim/ echo 'Linking configuration files done' else diff --git a/scripts/create_container b/scripts/create_container index 1beefe9..e9e77f7 100755 --- a/scripts/create_container +++ b/scripts/create_container @@ -5,38 +5,18 @@ PACKAGES="ca-certificates vim git dbus less locales man-db " REPO=https://github.com/SonnyBA/dotfiles.git if [ $EUID != 0 ]; then - echo "This script needs sudo priveleges (for systemd-nspawn)" - echo "Exiting..." - exit 1 + echo "This script needs sudo priveleges (for systemd-nspawn)" + echo "Exiting..." + exit 1 fi run() { - systemd-nspawn -D $CONTAINER_PATH $@ + systemd-nspawn -D $CONTAINER_PATH $@ } -add_ssh() { +config_ssh() { sed -i 's/^#Port .*/Port '"$PORT"'/' $CONTAINER_PATH/etc/ssh/sshd_config sed -i 's/^#PermitRootLogin .*/PermitRootLogin yes/' $CONTAINER_PATH/etc/ssh/sshd_config - - touch $CONTAINER_PATH/root/.profile - cat <<- 'EOF' > $CONTAINER_PATH/root/.bash_profile -# Start ssh-agent and add keys in ~/.ssh directory -# Should only be used without a desktop manager -ENV=/tmp/.agent_env -KEYS=$(basename --suffix=.pub -a $HOME/.ssh/*.pub) -if [ -z "$SSH_AGENT_PID" ] && [ ! -e "$ENV" ] ; then - ssh-agent > $ENV - source $ENV - for key in $KEYS; - do - ssh-add ~/.ssh/$key - done - echo 'Agent started' -else - source $ENV - echo 'Agent started already, good to go' -fi -EOF } dotfiles() { @@ -55,7 +35,7 @@ read -p "Append container to ssh user config? [y/n]: " USER_CONFIG if [ "$SSH_SERVER" == "y" ];then read -p "Enter ssh listening port: " PORT - PACKAGES+=" ssh " + PACKAGES+=" ssh " fi PACKAGES+=$EXTRA @@ -69,11 +49,11 @@ mkdir $CONTAINER_PATH/root/.ssh cp $KEY $KEY.pub $CONTAINER_PATH/root/.ssh/ if [ -n "$HOSTNAME" ] ;then - echo $HOSTNAME > $CONTAINER_PATH/etc/hostname + echo $HOSTNAME > $CONTAINER_PATH/etc/hostname fi if [ "$SSH_SERVER" == "y" ] ;then - add_ssh + config_ssh fi if [ "$DOTFILES" == "y" ] ;then @@ -81,15 +61,15 @@ if [ "$DOTFILES" == "y" ] ;then fi if [ "$USER_CONFIG" == "y" ]; then - cat <<- EOF >> /home/$SUDO_USER/.ssh/config + cat <<- EOF >> /home/$SUDO_USER/.ssh/config Host $HOSTNAME User root Hostname 127.0.0.1 Port $PORT EOF - # Remove leading whitespace - sed -i 's/^ *//g' /home/$SUDO_USER/.ssh/config +# Remove leading whitespace +sed -i 's/^ *//g' /home/$SUDO_USER/.ssh/config fi echo "Updating default pager to less" @@ -101,4 +81,4 @@ run passwd CONTAINER_NAME=$(basename $CONTAINER_PATH) echo "Container finished setting up, use ssh $HOSTNAME after starting the machine" \ - "with machinectl start $CONTAINER_NAME" + "with machinectl start $CONTAINER_NAME"