Commit 3e70ac1b authored by Alibek Omarov's avatar Alibek Omarov

grab, install: allow to select multiple packs

parent 44c9b4ed
#!/bin/sh
#!/bin/bash
function func_exists () {
if [ -n "$(type -t mode_$1)" ] && [ "$(type -t mode_$1)" == "function" ] ; then
......@@ -65,6 +65,8 @@ function mode_help () {
echo " prepare"
echo " grab [source] [options]"
echo " build [source] [name] [artist]"
echo " install [pack]..."
echo " recreate"
fi
}
......@@ -215,7 +217,7 @@ function mode_grab () {
}
function mode_help_grab_instance () {
echo "./stickers.sh grab instance [INSTANCE] [PACK]"
echo "./stickers.sh grab instance [INSTANCE] [PACK]..."
echo "grabs a stickerpack from an instance"
echo "options:"
echo " INSTANCE : the instance to grab a pack from"
......@@ -223,19 +225,19 @@ function mode_help_grab_instance () {
}
function mode_grab_instance () {
instance=$1
pack=$2
instance=$1; shift
packs=$@
if [ ! -n "$instance" ] ; then
echo "no instance"
exit
fi
releasePath=$(jq -r '.workspace.release' $config)
tmpPath=$(jq -r '.workspace.tmp' $config)
mkdir -p $tmpPath
wget -q "https://$instance/static/stickers.json" -O "$tmpPath/stickers.json"
if [ ! -n "$pack" ] ; then
if [ ! -n "$packs" ] ; then
keys=$(jq -r 'keys[]' "$tmpPath/stickers.json")
echo "listing packs:"
for key in $keys ; do
......@@ -247,25 +249,29 @@ function mode_grab_instance () {
echo "no pack picked"
exit
fi
pack=$packpick
packs=$packpick
fi
echo "downloading $pack..."
packPath=$(jq -r ".$pack" $tmpPath/stickers.json)
mkdir -p $releasePath/$pack/
echo -n "getting metadata..."
wget -q "https://$instance${packPath}pack.json" -O "$releasePath/$pack/pack.json"
echo "ok"
echo -n "getting tab icon..."
tabIcon=$(jq -r '.tabIcon' "$releasePath/$pack/pack.json")
wget -q "https://$instance${packPath}$tabIcon" -O "$releasePath/$pack/$tabIcon"
echo "ok"
echo "getting stickers..."
stickers=$(jq -r '.stickers[]' "$releasePath/$pack/pack.json")
for sticker in $stickers ; do
echo -n "downloading $sticker..."
wget -q "https://$instance${packPath}$sticker" -O "$releasePath/$pack/$sticker"
for pack in $packs; do
echo "downloading $pack..."
packPath=$(jq -r ".$pack" $tmpPath/stickers.json)
mkdir -p $releasePath/$pack/
echo -n "getting metadata..."
wget -q "https://$instance${packPath}pack.json" -O "$releasePath/$pack/pack.json"
echo "ok"
echo -n "getting tab icon..."
tabIcon=$(jq -r '.tabIcon' "$releasePath/$pack/pack.json")
wget -q "https://$instance${packPath}$tabIcon" -O "$releasePath/$pack/$tabIcon"
echo "ok"
echo "getting stickers..."
stickers=$(jq -r '.stickers[]' "$releasePath/$pack/pack.json")
for sticker in $stickers ; do
echo -n "downloading $sticker..."
wget -q "https://$instance${packPath}$sticker" -O "$releasePath/$pack/$sticker"
echo "ok"
done
done
echo -n "cleaning up..."
rm -Rf "$tmpPath"
echo "ok"
......@@ -327,28 +333,31 @@ function mode_grab_line () {
}
function mode_help_install () {
echo "./stickers.sh install [pack]"
echo "./stickers.sh install [PACK]..."
echo "installs sticker pack to pleroma"
echo "options:"
echo " - pack: path to pack to install"
echo " PACK: paths to packs to install"
exit
}
function mode_install () {
pack=$1
if [ -z "$pack" ] ; then
packs=$*
if [ -z "$packs" ] ; then
echo "no directory"
mode_help_install
fi
staticDir=$(jq -r '.pleroma.static' $config)
check_pleroma
echo "installing $pack..."
if [ ! -f "$pack/pack.json" ] ; then
echo "not a valid pleroma sticker pack"
echo "use './stickers.sh build $pack' to create one"
fi
cp -r "$pack" "$staticDir/static/stickers/"
echo "pack installed"
for pack in $packs; do
echo "installing $pack..."
if [ ! -f "$pack/pack.json" ] ; then
echo "not a valid pleroma sticker pack"
echo "use './stickers.sh build $pack' to create one"
else
cp -r "$pack" "$staticDir/static/stickers/"
echo "pack installed"
fi
done
mode_recreate
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment