lbry-sdk/packaging/ubuntu/lbry

40 lines
755 B
Text
Raw Normal View History

2016-04-13 00:50:47 +02:00
#!/bin/bash
set -euo pipefail
2016-05-24 23:50:01 +02:00
WEB_UI_BRANCH='master'
2016-04-13 00:50:47 +02:00
urlencode() {
local LANG=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;
*) printf '%%%02X' "'$c" ;;
esac
done
}
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ -z "$(pgrep lbrynet-daemon)" ]; then
echo "running lbrynet-daemon..."
2016-05-24 23:50:01 +02:00
$DIR/lbrynet-daemon --branch="$WEB_UI_BRANCH" &
2016-04-13 00:50:47 +02:00
sleep 3 # let the daemon load before connecting
fi
ARG=${1:-}
if [ -z "$ARG" ]; then
URL=""
else
2016-05-06 23:38:57 +02:00
NAME=$(echo "$ARG" | cut -c 8-)
if [ -z "$NAME" -o "$NAME" == "lbry" ]; then
URL=""
else
URL="/?watch=$(urlencode "$NAME")"
fi
2016-04-13 00:50:47 +02:00
fi
2016-05-06 23:38:57 +02:00
/usr/bin/xdg-open "http://localhost:5279$URL"