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

Add the 'update', 'get' and 'del' commands.

Also use commands in the path, no aliases and begin to update the README.
parent 42be925d
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -194,3 +194,17 @@ scp matrix-stickers/packs/*/*.json nom0000@perso.iiens.net:html/stickerpicker/we ...@@ -194,3 +194,17 @@ scp matrix-stickers/packs/*/*.json nom0000@perso.iiens.net:html/stickerpicker/we
4. Répéter jusqu'à avoir tous les stickers voulu dans le pack 4. Répéter jusqu'à avoir tous les stickers voulu dans le pack
5. Ajouter le json à index.json 5. Ajouter le json à index.json
## Utilisation de stpkg
La commande `stpkg` a besoin des executables `egrep` (ou `grep` si indisponible),
`sponge` et `jq`. Il faut donc les installer ou les recompiler sur votre machine
(`apt install moreutils jq grep`).
> Il faut avoir utiliser le script `install.sh` et bien mettre les variables
`STPKG_BASE` et `STPKG_INSTALL` dans votre bashrc pour que `stpkg` fonctionne.
Les commandes de `stpkg` :
- `stpkg update`
- `stpkg list`
- `stpkg get`
- `stpkg del`
...@@ -43,6 +43,7 @@ EOF ...@@ -43,6 +43,7 @@ EOF
if [ "x$DISPLAY_DEPS_NOTES" = "xyes" ]; then if [ "x$DISPLAY_DEPS_NOTES" = "xyes" ]; then
cat << EOF cat << EOF
Note: $0 requires 'jq' and 'egrep'. If 'egrep' is not found, 'grep' will be used. Note: $0 requires 'jq' and 'egrep'. If 'egrep' is not found, 'grep' will be used.
Note: 'git' is obviously required, but if you are using this repo you should have clone it so it's ok.
EOF EOF
fi fi
...@@ -67,6 +68,15 @@ else ...@@ -67,6 +68,15 @@ else
info "Use custom STPKG_INSTALL: $STPKG_INSTALL" info "Use custom STPKG_INSTALL: $STPKG_INSTALL"
fi fi
if [ "x$STPKG_BASE" = "x" ]; then
die "The STPKG_BASE env var is mendatory, it must point to the sticker repo." \
"It should have been given by the install script"
fi
__git=`which git`
[ $? -ne 0 ] && die "Failed to find the 'git' command, WTF?"
__sponge=`which sponge`
[ $? -ne 0 ] && die "Failed to find the 'sponge' command"
__jq=`which jq` __jq=`which jq`
[ $? -ne 0 ] && die "Failed to find the 'jq' command" [ $? -ne 0 ] && die "Failed to find the 'jq' command"
__grep=`which egrep` __grep=`which egrep`
...@@ -76,13 +86,26 @@ if [ $? -ne 0 ]; then ...@@ -76,13 +86,26 @@ if [ $? -ne 0 ]; then
warn "Cound not find 'grep', will use 'egrep 'instead" warn "Cound not find 'grep', will use 'egrep 'instead"
fi fi
DISPLAY_DEPS_NOTES="no" DISPLAY_DEPS_NOTES="no"
alias jq=$__jq
alias grep=$__grep
alias git=$__git
alias sponge=$__sponge
######################### #########################
# Cmd handler functions # # Cmd handler functions #
######################### #########################
__update() { __update() {
info "Updating packs" info "Updating packs..."
info "... update the sticker repo"
local LOCATION_OPT="--git-dir=$STPKG_BASE/.git --work-tree=$STPKG_BASE/"
git $LOCATION_OPT fetch || die "Failed to fetch from sticker repo"
git $LOCATION_OPT rebase || die "Failed to rebase... what did you do to your master branch?"
info "... update the sticker picker repo"
local LOCATION_OPT="--git-dir=$STPKG_INSTALL/.git --work-tree=$STPKG_INSTALL/"
git $LOCATION_OPT fetch || die "Failed to fetch from stickerpicker repo"
git $LOCATION_OPT rebase || die "Failed to rebase... what did you do to the master branch of the sticker picker?"
info "Update finished!"
} }
__list() { __list() {
...@@ -98,11 +121,16 @@ __list() { ...@@ -98,11 +121,16 @@ __list() {
__get() { __get() {
[ "x$1" = "x" ] && die "You must specify a pack for the 'get' command" [ "x$1" = "x" ] && die "You must specify a pack for the 'get' command"
info "Enable pack '$1'" info "Enable pack '$1'"
jq ".packs += [\"$1.json\"]" \
< $STPKG_INSTALL/web/packs/index.json | sponge $STPKG_INSTALL/web/packs/index.json
} }
__del() { __del() {
[ "x$1" = "x" ] && die "You must specify a pack 'del' command" [ "x$1" = "x" ] && die "You must specify a pack 'del' command"
info "Disable pack '$1'" info "Disable pack '$1'"
local INDEX=0
jq "{ \"homeserver_url\": .homeserver_url, \"packs\": .packs | map(select(. != \"$1.json\")) }" \
< $STPKG_INSTALL/web/packs/index.json | sponge $STPKG_INSTALL/web/packs/index.json
} }
###################### ######################
......
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