mirror of
https://github.com/lloeki/apply.git
synced 2025-12-06 01:14:39 +01:00
Locate units using APPLY_ROOT env var
This commit is contained in:
parent
8a178cdc2b
commit
44eeefea79
4 changed files with 21 additions and 5 deletions
4
Makefile
Normal file
4
Makefile
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
all:
|
||||
|
||||
lint:
|
||||
find apply run push lib -type f -not -iname '*.*' | xargs shellcheck -s bash
|
||||
6
apply
6
apply
|
|
@ -11,7 +11,7 @@ function usage() {
|
|||
function host_targets() {
|
||||
local host="$*"
|
||||
|
||||
cat < "$host" | tr '\n' ' '
|
||||
cat < "${APPLY_ROOT}"/"$host" | tr '\n' ' '
|
||||
}
|
||||
|
||||
function push_each() {
|
||||
|
|
@ -28,6 +28,10 @@ function push_each() {
|
|||
fi
|
||||
}
|
||||
|
||||
if [[ -z "${APPLY_ROOT:-}" ]]; then
|
||||
APPLY_ROOT="."
|
||||
fi
|
||||
|
||||
if [[ $# -lt 1 ]]; then
|
||||
usage
|
||||
fi
|
||||
|
|
|
|||
6
push
6
push
|
|
@ -8,6 +8,10 @@ function usage() {
|
|||
exit 1
|
||||
}
|
||||
|
||||
if [[ -z "${APPLY_ROOT:-}" ]]; then
|
||||
APPLY_ROOT="."
|
||||
fi
|
||||
|
||||
if [[ $# -lt 1 ]]; then
|
||||
usage
|
||||
fi
|
||||
|
|
@ -33,7 +37,7 @@ remote="$1"
|
|||
|
||||
tmp=$(ssh "$remote" 'mktemp -d')
|
||||
echo -e -n "\033[33m** pushing to\033[0m $remote:$tmp"
|
||||
if scp -q -r groups units run lib "$remote":"$tmp"; then
|
||||
if scp -q -r "${APPLY_ROOT}"/{groups,units,run,lib} "$remote":"$tmp"; then
|
||||
echo -e " \033[32mOK\033[0m"
|
||||
fi
|
||||
|
||||
|
|
|
|||
8
run
8
run
|
|
@ -9,7 +9,11 @@ function usage() {
|
|||
}
|
||||
|
||||
function root_path() {
|
||||
cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd
|
||||
if [[ -z "${APPLY_ROOT:-}" ]]; then
|
||||
cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd
|
||||
else
|
||||
echo "$APPLY_ROOT"
|
||||
fi
|
||||
}
|
||||
|
||||
function read_group() {
|
||||
|
|
@ -33,7 +37,7 @@ function run_group() {
|
|||
}
|
||||
|
||||
function run_unit() {
|
||||
/bin/bash -l -c "set -e; set -u; set -o pipefail; source lib; source '$*'"
|
||||
/bin/bash -l -c "set -e; set -u; set -o pipefail; source lib; source '$(root_path)/$*'"
|
||||
}
|
||||
|
||||
function log_file() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue