also use .profile when linking
This commit is contained in:
parent
af3cb0b171
commit
30660d51d9
2 changed files with 14 additions and 34 deletions
|
|
@ -18,7 +18,7 @@ function user_config {
|
||||||
mv $HOME/.bashrc $HOME/.bashrc.old
|
mv $HOME/.bashrc $HOME/.bashrc.old
|
||||||
echo "Old .bashrc moved to .bashrc.old"
|
echo "Old .bashrc moved to .bashrc.old"
|
||||||
fi
|
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/
|
ln -s $SCRIPTPATH/vim/colors $HOME/.vim/
|
||||||
echo 'Linking configuration files done'
|
echo 'Linking configuration files done'
|
||||||
elif [[ "$USER" == "root" ]]; then
|
elif [[ "$USER" == "root" ]]; then
|
||||||
|
|
@ -28,7 +28,7 @@ function user_config {
|
||||||
mv /root/.bashrc /root/.bashrc.old
|
mv /root/.bashrc /root/.bashrc.old
|
||||||
echo "Old .bashrc moved to .bashrc.old"
|
echo "Old .bashrc moved to .bashrc.old"
|
||||||
fi
|
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/
|
ln -s $SCRIPTPATH/vim/colors /root/.vim/
|
||||||
echo 'Linking configuration files done'
|
echo 'Linking configuration files done'
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -5,38 +5,18 @@ PACKAGES="ca-certificates vim git dbus less locales man-db "
|
||||||
REPO=https://github.com/SonnyBA/dotfiles.git
|
REPO=https://github.com/SonnyBA/dotfiles.git
|
||||||
|
|
||||||
if [ $EUID != 0 ]; then
|
if [ $EUID != 0 ]; then
|
||||||
echo "This script needs sudo priveleges (for systemd-nspawn)"
|
echo "This script needs sudo priveleges (for systemd-nspawn)"
|
||||||
echo "Exiting..."
|
echo "Exiting..."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
run() {
|
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/^#Port .*/Port '"$PORT"'/' $CONTAINER_PATH/etc/ssh/sshd_config
|
||||||
sed -i 's/^#PermitRootLogin .*/PermitRootLogin yes/' $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() {
|
dotfiles() {
|
||||||
|
|
@ -55,7 +35,7 @@ read -p "Append container to ssh user config? [y/n]: " USER_CONFIG
|
||||||
|
|
||||||
if [ "$SSH_SERVER" == "y" ];then
|
if [ "$SSH_SERVER" == "y" ];then
|
||||||
read -p "Enter ssh listening port: " PORT
|
read -p "Enter ssh listening port: " PORT
|
||||||
PACKAGES+=" ssh "
|
PACKAGES+=" ssh "
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PACKAGES+=$EXTRA
|
PACKAGES+=$EXTRA
|
||||||
|
|
@ -69,11 +49,11 @@ mkdir $CONTAINER_PATH/root/.ssh
|
||||||
cp $KEY $KEY.pub $CONTAINER_PATH/root/.ssh/
|
cp $KEY $KEY.pub $CONTAINER_PATH/root/.ssh/
|
||||||
|
|
||||||
if [ -n "$HOSTNAME" ] ;then
|
if [ -n "$HOSTNAME" ] ;then
|
||||||
echo $HOSTNAME > $CONTAINER_PATH/etc/hostname
|
echo $HOSTNAME > $CONTAINER_PATH/etc/hostname
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$SSH_SERVER" == "y" ] ;then
|
if [ "$SSH_SERVER" == "y" ] ;then
|
||||||
add_ssh
|
config_ssh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$DOTFILES" == "y" ] ;then
|
if [ "$DOTFILES" == "y" ] ;then
|
||||||
|
|
@ -81,15 +61,15 @@ if [ "$DOTFILES" == "y" ] ;then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$USER_CONFIG" == "y" ]; then
|
if [ "$USER_CONFIG" == "y" ]; then
|
||||||
cat <<- EOF >> /home/$SUDO_USER/.ssh/config
|
cat <<- EOF >> /home/$SUDO_USER/.ssh/config
|
||||||
|
|
||||||
Host $HOSTNAME
|
Host $HOSTNAME
|
||||||
User root
|
User root
|
||||||
Hostname 127.0.0.1
|
Hostname 127.0.0.1
|
||||||
Port $PORT
|
Port $PORT
|
||||||
EOF
|
EOF
|
||||||
# Remove leading whitespace
|
# Remove leading whitespace
|
||||||
sed -i 's/^ *//g' /home/$SUDO_USER/.ssh/config
|
sed -i 's/^ *//g' /home/$SUDO_USER/.ssh/config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Updating default pager to less"
|
echo "Updating default pager to less"
|
||||||
|
|
@ -101,4 +81,4 @@ run passwd
|
||||||
CONTAINER_NAME=$(basename $CONTAINER_PATH)
|
CONTAINER_NAME=$(basename $CONTAINER_PATH)
|
||||||
|
|
||||||
echo "Container finished setting up, use ssh $HOSTNAME after starting the machine" \
|
echo "Container finished setting up, use ssh $HOSTNAME after starting the machine" \
|
||||||
"with machinectl start $CONTAINER_NAME"
|
"with machinectl start $CONTAINER_NAME"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue