diff --git a/stpkg b/stpkg index 1c3de3d7d66cdc6f1a4c58ba26b7755fdfecbc5a..33f1a00152a205f32e30ba08ea999a7d22e06a00 100755 --- a/stpkg +++ b/stpkg @@ -66,9 +66,6 @@ fi SELF=`readlink -f "$0"` MD5=`md5sum $SELF` -# Source conf file, may have the sshfs hook -[ -f $STPKG_CONF_FILE ] && source $STPKG_CONF_FILE - if [ "x$STPKG_NO_MSG" = "xyes" -a ! "x$1" = "x-install" -a ! "x$1" = "xupdate" ]; then # Do not silence errors warn() { return 0; } @@ -296,14 +293,18 @@ STPKG_SSHFS='yes' STPKG_INSTALL="$STPKG_INSTALL" SSHFS_USER="$SSHFS" SSHFS_MNT="`echo "$MNT" | sed "s+$HOME+~+g"`" -mountpoint $MNT >/dev/null 2>&1 -[ \$? -ne 0 -a ! "x\$INSTALL" = "xyes" ] && { - [ ! -d "\$STPKG_INSTALL" ] && { - sshfs $SSHFS: $MNT \ - || die "Failed to mount $SSHFS:~/ to $MNT"; +fi + +__do_mount() { + mountpoint $MNT >/dev/null 2>&1 + [ \$? -ne 0 -a ! "x\$INSTALL" = "xyes" ] && { + [ ! -d "\$STPKG_INSTALL" ] && { + sshfs $SSHFS: $MNT \ + || die "Failed to mount $SSHFS:~/ to $MNT"; + } + [ ! -d "\$STPKG_INSTALL" ] \ + && die 'Failed to mount $SSHFS:~/ to $MNT, sshfs problems?' } - [ ! -d "\$STPKG_INSTALL" ] \ - && die 'Failed to mount $SSHFS:~/ to $MNT, sshfs problems?' } EOF @@ -326,8 +327,9 @@ EOF # Clone and copy packs info "Will install sticker picker in folder: $STPKG_INSTALL" - git clone https://github.com/maunium/stickerpicker.git "$STPKG_INSTALL" \ - || die "Failed to git clone the stickerpicker project." + + git clone "$STPKG_STICKER_REPO" "$STPKG_INSTALL" \ + || die "Failed to git clone the stickerpicker project. Your config file ($STPKG_CONF_FILE) is probably corrupted, you should clean it by hand" cd $STPKG_INSTALL/ || die "Failed to cd to '$STPKG_INSTALL/'" cp packs/* web/packs || die "Failed to copy default packs to '$STPKG_INSTALL/web/packs/'" @@ -337,6 +339,7 @@ EOF echo "fi" >> $STPKG_CONF_FILE info "You may edit the $STPKG_CONF_FILE to setup your home server and token (variable STPKG_TOKEN)" } + if [ "x$1" = "x-install" ]; then [ "x$STPKG_NO_MSG" = "xyes" ] \ && echo "!!! STPKG_NO_MSG is turn on, you won't see what's going on during the install" @@ -349,20 +352,6 @@ if [ "x$1" = "x-install" ]; then exit 0 fi -######################### -# Get some exec / paths # -######################### - -STPKG_INSTALL=${STPKG_INSTALL:="~/html/stickerpicker/"} -if [ ! -d "$STPKG_INSTALL" ]; then - error "STPKG_INSTALL folder ($STPKG_INSTALL) doesn't exist. Did you use the install script?" - usage -fi -info "Using STPKG_INSTALL: $STPKG_INSTALL`[ "x$STPKG_SSHFS" = "xyes" ] && echo ' (this is an sshfs install)'`" - -[ "x$STPKG_BASE" = "x" ] && die \ - "The STPKG_BASE env var is mendatory, it must point to the sticker repo. It should have been given by the install script" - ######################### # Cmd handler functions # ######################### @@ -784,16 +773,48 @@ __pack() { # Parse command line # ###################### +__do_command() { + case "$1" in + show|update|list|add|del|default|pack|display|edit) + # Source conf file, may have the sshfs hook + if [ -f $STPKG_CONF_FILE ]; then + source $STPKG_CONF_FILE + else + error "Conf file \"$STPKG_CONF_FILE\" doesn't exist. Did you use the install command?" + error "Help:" + usage + fi + + __do_mount + + # Get some exec / paths # + STPKG_INSTALL=${STPKG_INSTALL:="~/html/stickerpicker/"} + if [ ! -d "$STPKG_INSTALL" ]; then + error "STPKG_INSTALL folder ($STPKG_INSTALL) doesn't exist. Did you use the install script?" + usage + fi + info "Using STPKG_INSTALL: $STPKG_INSTALL`[ "x$STPKG_SSHFS" = "xyes" ] && echo ' (this is an sshfs install)'`" + + [ "x$STPKG_BASE" = "x" ] && die \ + "The STPKG_BASE env var is mendatory, it must point to the sticker repo. It should have been given by the install script" + ;; + + *) + ;; + esac + $* +} + [ "x$1" = "x" ] && usage case "$1" in - show) __show ;; - update) __update ;; - list) shift; __list $* ;; - add) shift; __add $* ;; - del) shift; __del $* ;; - default) __default ;; - pack) shift; __pack $* ;; - display) shift; __display $*;; - edit) shift; __edit $* ;; - *) usage ;; + show) __do_command show ;; + update) __do_command update ;; + list) shift; __do_command list $* ;; + add) shift; __do_command add $* ;; + del) shift; __do_command del $* ;; + default) __do_command default ;; + pack) shift; __do_command pack $* ;; + display) shift; __do_command display $*;; + edit) shift; __do_command edit $* ;; + *) __do_command usage ;; esac