blob: b89b4bf8fe0819378d58f9e646ab0bfb0de22c0a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#!/bin/sh
set -eu -o pipefail
prog=$(basename "$(readlink -f "$0")")
usage="${prog} [-q] INVIDIOUS_USER INVIDIOUS_SRCDIR"
die() {
printf '%s: %s\n' "$prog" "$*" 1>&2
exit 1
}
usage(){
printf 'usage: %s\n' "$usage" 1>&2
exit 2
}
as_invidious(){
su -m "$invidious_user" -c "HOME=$(dirname "$invidious_dir") ${@}"
}
while getopts hq opt; do
case $opt in
h) usage ;;
q) exec 1>/dev/null ;;
esac
done
shift $((OPTIND - 1))
[ $# -eq 2 ] || usage
invidious_user=$1
invidious_dir=$2
cd "$invidious_dir"
su -m "$invidious_user" -c 'git fetch'
local_rev=$(as_invidious 'git rev-parse HEAD')
upstream_rev=$(as_invidious 'git rev-parse "@{u}"')
if [ "$local_rev" != "$upstream_rev" ]; then
echo "updating invidious to rev ${upstream_rev}"
as_invidious 'git pull --ff-only && shards install --production && crystal build src/invidious.cr --release'
else
echo "invidious already up to date at rev ${local_rev}"
fi
service invidious restart
|