30 lines
521 B
Bash
30 lines
521 B
Bash
|
#!/usr/bin/env bash
|
||
|
DEPLOY_HOST=$1
|
||
|
DEPLOY_ADDRESS=$2
|
||
|
DEPLOY_PORT=$3
|
||
|
|
||
|
if [ -z $DEPLOY_HOST ]; then
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
cmd=" \
|
||
|
nixos-rebuild switch \
|
||
|
-I nixos-config=hosts/${DEPLOY_HOST}/configuration.nix \
|
||
|
"
|
||
|
|
||
|
if [ -z $DEPLOY_ADDRESS ] || [ $DEPLOY_ADDRESS = "-" ]; then
|
||
|
DEPLOY_ADDRESS="root@${DEPLOY_HOST}.net.entr0py.de"
|
||
|
fi
|
||
|
|
||
|
if [ $DEPLOY_ADDRESS != "localhost" ]; then
|
||
|
cmd="${cmd} \
|
||
|
--target-host ${DEPLOY_ADDRESS} \
|
||
|
"
|
||
|
fi
|
||
|
|
||
|
if [ -n "$DEPLOY_PORT" ]; then
|
||
|
cmd="NIX_SSHOPTS=\"-p $DEPLOY_PORT\" ${cmd}"
|
||
|
fi
|
||
|
|
||
|
eval ${cmd}
|