Skip to content
Extraits de code Groupes Projets
Valider 9e2f3382 rédigé par Elliu's avatar Elliu
Parcourir les fichiers

Print warnings and try mounting only if needed

Show help and exit if no config file is found

Fix configuration generation
parent 956e8d74
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -66,9 +66,6 @@ fi ...@@ -66,9 +66,6 @@ fi
SELF=`readlink -f "$0"` SELF=`readlink -f "$0"`
MD5=`md5sum $SELF` 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 if [ "x$STPKG_NO_MSG" = "xyes" -a ! "x$1" = "x-install" -a ! "x$1" = "xupdate" ]; then
# Do not silence errors # Do not silence errors
warn() { return 0; } warn() { return 0; }
...@@ -296,6 +293,9 @@ STPKG_SSHFS='yes' ...@@ -296,6 +293,9 @@ STPKG_SSHFS='yes'
STPKG_INSTALL="$STPKG_INSTALL" STPKG_INSTALL="$STPKG_INSTALL"
SSHFS_USER="$SSHFS" SSHFS_USER="$SSHFS"
SSHFS_MNT="`echo "$MNT" | sed "s+$HOME+~+g"`" SSHFS_MNT="`echo "$MNT" | sed "s+$HOME+~+g"`"
fi
__do_mount() {
mountpoint $MNT >/dev/null 2>&1 mountpoint $MNT >/dev/null 2>&1
[ \$? -ne 0 -a ! "x\$INSTALL" = "xyes" ] && { [ \$? -ne 0 -a ! "x\$INSTALL" = "xyes" ] && {
[ ! -d "\$STPKG_INSTALL" ] && { [ ! -d "\$STPKG_INSTALL" ] && {
...@@ -305,6 +305,7 @@ mountpoint $MNT >/dev/null 2>&1 ...@@ -305,6 +305,7 @@ mountpoint $MNT >/dev/null 2>&1
[ ! -d "\$STPKG_INSTALL" ] \ [ ! -d "\$STPKG_INSTALL" ] \
&& die 'Failed to mount $SSHFS:~/ to $MNT, sshfs problems?' && die 'Failed to mount $SSHFS:~/ to $MNT, sshfs problems?'
} }
}
EOF EOF
# Do the sshfs hook # Do the sshfs hook
...@@ -326,8 +327,9 @@ EOF ...@@ -326,8 +327,9 @@ EOF
# Clone and copy packs # Clone and copy packs
info "Will install sticker picker in folder: $STPKG_INSTALL" 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/'" 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/'" cp packs/* web/packs || die "Failed to copy default packs to '$STPKG_INSTALL/web/packs/'"
...@@ -337,6 +339,7 @@ EOF ...@@ -337,6 +339,7 @@ EOF
echo "fi" >> $STPKG_CONF_FILE echo "fi" >> $STPKG_CONF_FILE
info "You may edit the $STPKG_CONF_FILE to setup your home server and token (variable STPKG_TOKEN)" info "You may edit the $STPKG_CONF_FILE to setup your home server and token (variable STPKG_TOKEN)"
} }
if [ "x$1" = "x-install" ]; then if [ "x$1" = "x-install" ]; then
[ "x$STPKG_NO_MSG" = "xyes" ] \ [ "x$STPKG_NO_MSG" = "xyes" ] \
&& echo "!!! STPKG_NO_MSG is turn on, you won't see what's going on during the install" && 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 ...@@ -349,20 +352,6 @@ if [ "x$1" = "x-install" ]; then
exit 0 exit 0
fi 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 # # Cmd handler functions #
######################### #########################
...@@ -784,16 +773,48 @@ __pack() { ...@@ -784,16 +773,48 @@ __pack() {
# Parse command line # # 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 [ "x$1" = "x" ] && usage
case "$1" in case "$1" in
show) __show ;; show) __do_command show ;;
update) __update ;; update) __do_command update ;;
list) shift; __list $* ;; list) shift; __do_command list $* ;;
add) shift; __add $* ;; add) shift; __do_command add $* ;;
del) shift; __del $* ;; del) shift; __do_command del $* ;;
default) __default ;; default) __do_command default ;;
pack) shift; __pack $* ;; pack) shift; __do_command pack $* ;;
display) shift; __display $*;; display) shift; __do_command display $*;;
edit) shift; __edit $* ;; edit) shift; __do_command edit $* ;;
*) usage ;; *) __do_command usage ;;
esac esac
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter