Skip to content

Commit

Permalink
refactor install and uninstall scripts to streamline SSH configuratio…
Browse files Browse the repository at this point in the history
…n handling and ensure OUTFILE path is absolute
  • Loading branch information
BrightXiaoHan committed Dec 29, 2024
1 parent f56f313 commit 90150d1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
13 changes: 2 additions & 11 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ rm -rf ~/.config/nvim \
~/.config/tmux \
~/.config/fish \
~/.gitconfig \
~/.ssh/config \
~/.ssh/id_rsa.pub \
~/.mambarc

# remove nvim plugins
Expand Down Expand Up @@ -143,22 +141,15 @@ else
exit 1
fi

if [ ! -d ~/.ssh ]; then
mkdir ~/.ssh
fi
ln -sf $DIR/ssh/config ~/.ssh/config
ln -sf $DIR/ssh/id_rsa.pub ~/.ssh/id_rsa.pub

# add authorized_keys into .ssh/authorized_keys
if [ ! -f ~/.ssh/authorized_keys ]; then
touch ~/.ssh/authorized_keys
fi
# if id_rsa.pub not in authorized_keys, add it
if ! grep -q "$(cat ~/.ssh/id_rsa.pub)" ~/.ssh/authorized_keys; then
cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
if ! grep -q "$(cat $INSTALL_DIR/HOME/general/ssh/id_rsa.pub)" ~/.ssh/authorized_keys; then
cat $INSTALL_DIR/HOME/general/ssh/id_rsa.pub >>~/.ssh/authorized_keys
fi

ln -sf $DIR/gitconfig ~/.gitconfig
ln -sf $DIR/mambarc ~/.mambarc

if [ "$MODE" = "local-install" ] || [ "$MODE" = "online-install" ]; then
Expand Down
7 changes: 6 additions & 1 deletion scripts/pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,10 @@ cp $INSTALL_DIR/HOME/scripts/install.sh \
$INSTALL_DIR/HOME/scripts/uninstall.sh \
$INSTALL_DIR/HOME/scripts/_unpack.sh \
$INSTALL_DIR/packed
./HOME/scripts/makeself/makeself.sh ./packed $CURDIR/$OUTFILE "HOME Installer" ./_unpack.sh

# if OUTFILE is a relative path, make it absolute
if [[ ! "$OUTFILE" = /* ]]; then
OUTFILE=$CURDIR/$OUTFILE
fi
./HOME/scripts/makeself/makeself.sh ./packed $OUTFILE "HOME Installer" ./_unpack.sh
cd -
3 changes: 0 additions & 3 deletions scripts/uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ REMOVE_CACHE=${REMOVE_CACHE:-true}
rm ~/.config/nvim \
~/.config/tmux \
~/.config/fish \
~/.gitconfig \
~/.ssh/config \
~/.ssh/id_rsa.pub \
~/.mambarc

# remove nvim plugins
Expand Down

0 comments on commit 90150d1

Please sign in to comment.