]> git.armaanb.net Git - asd-repo.git/blob - kiss-serv/files/kiss-send-build
mutt: remove /etc/Mutt*
[asd-repo.git] / kiss-serv / files / kiss-send-build
1 #!/usr/bin/sh -e
2
3 usage() {
4   echo 'Usage: kiss send-build [command] [options]
5 build KISS packages on a remote server
6
7 Options:
8   -h, --help        show this help message
9
10 Subcommands:
11   build [package]   initiate a remote build
12   status            get current remote status
13   status [package]  get current remote status of a package
14   get [package]     receive a built package
15
16 Configuration:
17   Done via environment variables
18
19   $KISS_SERV_HOST   remote host to connect to
20                       (defaults to localhost)
21   $KISS_SERV_USER   remote host to connect to
22                       (defaults to $(whoami))
23   $KISS_SERV_PORT   remote port to connect to
24                       (defaults to 22)'
25 }
26
27 parse_err() {
28   echo "$1"
29   $2
30   exit 2
31 }
32
33 sshexec() {
34   $sshcmd kiss serv $1 $2
35   exit
36 }
37
38 get() {
39   pkg=$($sshcmd 'ls -1 ~/.cache/kiss/bin/' | sort | grep -m 1 "$2")
40   rsync -azre "ssh -p $port" "$user@$host":/home/"$user"/.cache/kiss/bin/"$pkg" \
41     ~/.cache/kiss/bin
42   echo "fetched $pkg from $host"
43   exit
44 }
45
46 port=${KISS_SERV_PORT:-22}
47 host=${KISS_SERV_HOST:-localhost}
48 user=${KISS_SERV_USER:-$(whoami)}
49 sshcmd="ssh -p $port $user@$host env KISS_PATH=$KISS_PATH"
50
51 while [ "$1" != "" ]; do
52   case $1 in
53     -h | --help)
54       usage
55       exit
56       ;;
57     status | build)
58       sshexec "$@"
59       ;;
60     get)
61       "$1" "$@"
62       ;;
63     *)
64       parse_err "ERROR: unknown option $1 \n" usage
65       ;;
66   esac
67   shift 2
68 done
69 parse_err "ERROR: no command given\n" usage