From 1577d388a3a63ce93a1497f3e8031dd4ec2b5daf Mon Sep 17 00:00:00 2001 From: salixor <salixor@pm.me> Date: Sat, 20 Apr 2024 03:23:19 +0900 Subject: [PATCH] stpkg: Make it possible to provide alternative port for sshfs --- stpkg | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/stpkg b/stpkg index 3fdbb12..d1c2fe5 100755 --- a/stpkg +++ b/stpkg @@ -101,7 +101,7 @@ __usage() { echo `__bold "$BASE_NAME usage:"` local BASE_NAME=`__green "$BASE_NAME"` cat << EOF - $BASE_NAME -install [`__yellow "-sshfs 'username@server' -local mnt_point -pickerrepo 'foo@git.fr:stickerpicker.git'"`] [`__yellow "install_path"`] + $BASE_NAME -install [`__yellow "-sshfs 'username@server' -port '22' -local mnt_point -pickerrepo 'foo@git.fr:stickerpicker.git'"`] [`__yellow "install_path"`] $BASE_NAME show $BASE_NAME help $BASE_NAME update @@ -272,16 +272,21 @@ __install() { local SSHFS="$2" shift 2 ;; + -port) + local SSHFS_PORT="$2" + shift 2 + ;; -local) local MNT="$2" shift 2 ;; - *) + *) local PARSE_FLAGS=0 ;; esac done STPKG_STICKER_REPO=${STPKG_STICKER_REPO:="https://github.com/maunium/stickerpicker.git"} + SSHFS_PORT=${SSHFS_PORT:="22"} # Create the ~/.config/stpkg.sh [ ! -d ~/.config ] && mkdir ~/.config @@ -313,18 +318,18 @@ EOF local STPKG_INSTALL=$MNT${STPKG_INSTALL:="/html/stickerpicker/"} # The sshfs hook -cat >> $STPKG_CONF_FILE << EOF -STPKG_SSHFS='yes' -STPKG_INSTALL="$STPKG_INSTALL" -SSHFS_USER="$SSHFS" -SSHFS_MNT="`echo "$MNT" | sed "s+$HOME+~+g"`" -fi + cat >> $STPKG_CONF_FILE << EOF + STPKG_SSHFS='yes' + STPKG_INSTALL="$STPKG_INSTALL" + SSHFS_USER="$SSHFS" + SSHFS_MNT="`echo "$MNT" | sed "s+$HOME+~+g"`" + fi __do_mount() { mountpoint $MNT >/dev/null 2>&1 [ \$? -ne 0 -a ! "x\$INSTALL" = "xyes" ] && { [ ! -d "\$STPKG_INSTALL" ] && { - sshfs $SSHFS: $MNT \ + sshfs $SSHFS: -p $SSHFS_PORT $MNT \ || die "Failed to mount $SSHFS:~/ to $MNT"; } [ ! -d "\$STPKG_INSTALL" ] \ @@ -338,7 +343,7 @@ EOF mkdir "$MNT" mountpoint $MNT >/dev/null 2>&1 [ $? -eq 0 ] && die "The '$MNT' folder is already a mountpoint" - sshfs $SSHFS: $MNT || die "Failed to mount $SSHFS:~/ to $MNT" + sshfs $SSHFS: -p $SSHFS_PORT $MNT || die "Failed to mount $SSHFS:~/ to $MNT" else local STPKG_INSTALL=$1 local STPKG_INSTALL=${STPKG_INSTALL:="~/html/stickerpicker/"} -- GitLab