diff --git a/.gitignore b/.gitignore index d26b33daea1ed9823a189992bba38fbc913483c1..87f0ab8b610b1c99e78a634e8253940565b4d83a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ working +stickerpicker/ diff --git a/install.sh b/install.sh index dbd8cfb1fed2461bb1b17874db5f49266fb3e29d..6502f3dd7076aa6455c2a939e171b57953f16342 100755 --- a/install.sh +++ b/install.sh @@ -1,20 +1,51 @@ #!/bin/bash +BASE_DIR="$PWD" + +die() { + error $* + cd $PWD # Go to initial directory + exit 1 +} + +error() { + echo -ne '\e[31m'$*'\e[39m\n' +} + +warn() { + echo -ne '\e[33m'$*'\e[39m\n' +} + +info() { + echo -ne '\e[32m'$*'\e[39m\n' +} + # Clone the stickerpicker into the html repository -cd ~/html -git clone https://github.com/maunium/stickerpicker.git +cd ~/html >/dev/null 2>&1 \ + || warn "Could not cd to '~/html', will clone to '$PWD/stickerpicker'" + +git clone https://github.com/maunium/stickerpicker.git stickerpicker \ + || die "Failed to git clone the stickerpicker project." \ + "If you already installed stickerpicker, remove it or use the 'stpkg' command" # Initialize the stickerpicker with the pack # scalar-privacy_pam.json -cd stickerpicker -mv packs/* web/packs -cd web/packs -touch index.json -echo "{ - \"homeserver_url\": \"https://matrix.iiens.net\", - \"packs\": [ - \"scalar-privacy_pam.json\" +cd stickerpicker || die "Could not cd to '$PWD/stickerpicker'" +mv packs/* web/packs || die "Failed to cp packs to '$PWD/web/packs'" +cd web/packs || die "Failed to cd to '$PWD/web/packs'" + +cat > index.json << EOF +{ + "homeserver_url": "https://matrix.iiens.net", + "packs": [ + "scalar-privacy_pam.json" ] } -" >> index.json -echo "Created index.json in ~/html/stickerpicker/web/packs" +EOF + +[ ! -f index.json ] && die "Failed to create the $PWD/index.json file" + +info "Created index.json in '$PWD'" + +# Go to initial directory +cd $BASE_DIR