Skip to content
Extraits de code Groupes Projets
Valider 42be925d rédigé par Kubat's avatar Kubat
Parcourir les fichiers

Base stpkg script

parent d875cc12
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
#!/bin/bash
BASE_DIR="$PWD"
DISPLAY_DEPS_NOTES="yes"
if [ "x$STPKG_COLORS" = "x" ]; then
STPKG_COLORS="yes"
error() { echo -ne '\e[31m'$*'\e[39m\n' >/dev/stderr; }
warn() { echo -ne '\e[33m'$*'\e[39m\n' >/dev/stderr; }
info() { echo -ne '\e[32m'$*'\e[39m\n' >/dev/stderr; }
else
STPKG_COLORS="no"
error() { echo 'ERROR:' $* >/dev/stderr; }
warn() { echo 'WARN:' $* >/dev/stderr; }
info() { echo 'INFO:' $* >/dev/stderr; }
fi
########################
# Some basic functions #
########################
__exit() {
cd "$BASE_DIR"
exit $1
}
usage() {
cat << EOF
$0 usage:
$0 update
$0 list [egrep regex]
$0 get <pack>
$0 del <pack>
ENV variables:
STPKG_INSTALL The cloned stickerpicker project location. Defaut is ~/html/stickerpicker.
STPKG_BASE Where the sticker project is located.
STPKG_COLORS Use colors for output. Default is 'yes'.
The STPKG_INSTALL STPKG_BASE should have been given by the 'install.sh' script.
EOF
if [ "x$DISPLAY_DEPS_NOTES" = "xyes" ]; then
cat << EOF
Note: $0 requires 'jq' and 'egrep'. If 'egrep' is not found, 'grep' will be used.
EOF
fi
__exit 0
}
die() {
error $*
__exit 1
}
#########################
# Get some exec / paths #
#########################
if [ "x$STPKG_INSTALL" = "x" ]; then
STPKG_INSTALL="~/html/stickerpicker/"
[ ! -d "$STPKG_INSTALL" ] \
&& die "STPKG_INSTALL not specified but the default one ($STPKG_INSTALL) doesn't exist." \
"Did you use the install script?"
else
info "Use custom STPKG_INSTALL: $STPKG_INSTALL"
fi
__jq=`which jq`
[ $? -ne 0 ] && die "Failed to find the 'jq' command"
__grep=`which egrep`
if [ $? -ne 0 ]; then
__grep=`which grep`
[ $? -ne 0 ] && die "Failed to find 'grep' or 'egrep'"
warn "Cound not find 'grep', will use 'egrep 'instead"
fi
DISPLAY_DEPS_NOTES="no"
#########################
# Cmd handler functions #
#########################
__update() {
info "Updating packs"
}
__list() {
if [ "x$*" = "x" ]; then
REG=
info "List packs with no regex"
else
REG="$*"
info "List packs with regex: $REG"
fi
}
__get() {
[ "x$1" = "x" ] && die "You must specify a pack for the 'get' command"
info "Enable pack '$1'"
}
__del() {
[ "x$1" = "x" ] && die "You must specify a pack 'del' command"
info "Disable pack '$1'"
}
######################
# Parse command line #
######################
[ "x$1" = "x" ] && usage
case "$1" in
update)
__update
;;
list)
shift
__list "$*"
;;
get)
shift
__get $*
;;
del)
shift
__del $*
;;
esac
__exit 0
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