blob: d07b0fdd17e8097ec4cc1693f6037e6ee4fe43d6 (
plain)
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
|
#!/usr/bin/env bash
# Wraps aursync command to mount an amazon s3 bucket which contains a repository
cfg_name=dangersalad-reposync.config
cfg_file="${DANGERSALAD_REPOSYNC_CONFIG:-/etc/xdg/$cfg_name}"
cfg_file_system="$cfg_file"
set -uo pipefail
trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
if [[ ! -f $cfg_file ]]
then
cfg_file="${XDG_CONFIG_HOME:-$HOME/.config}/$cfg_name"
if [[ ! -f $cfg_file ]]
then
echo "Missing config file $cfg_file_system and $cfg_file"
exit 1
fi
fi
source "$cfg_file"
exit_cmd=""
defer() { exit_cmd="$@; $exit_cmd"; }
trap 'bash -c "$exit_cmd"' EXIT
repo="$(mktemp -d)"
defer "rmdir '$repo'"
s3fs "${bucket}" "$repo" -o "nosuid,nodev,default_acl=public-read,url=$bucket_url,nomultipart"
defer "fusermount -u '$repo'"
mkdir -p "$repo/${repo_path}"
echo "Performing system update"
sudo pacman -Syu
echo "Performing repository sync"
aursync --sign --repo "$repo_name" --root "$repo/$repo_path" "$@"
|