initial commit
This commit is contained in:
57
ec2-build-docker-host
Executable file
57
ec2-build-docker-host
Executable file
@@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage:
|
||||
$(basename "$0") [OPTION...]
|
||||
|
||||
Options:
|
||||
-h Print this help
|
||||
-i Path to SSH identity file
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
while getopts i:h opt; do
|
||||
case "$opt" in
|
||||
i)
|
||||
identityFile="${OPTARG}"
|
||||
;;
|
||||
h)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
\?)
|
||||
usage >&2
|
||||
exit 64
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
if [ -z ${identityFile} ]; then
|
||||
echo "missing option: -i is required" >&2
|
||||
usage >&2
|
||||
exit 64
|
||||
fi
|
||||
|
||||
if [ -z $(type -P "scp") ] || [ -z $(type -P "ssh") ]; then
|
||||
echo "SSH needs to be installed" >&2
|
||||
exit 64
|
||||
fi
|
||||
|
||||
echo "Please open $(tput bold)https://nixos.org/download#nixos-amazon$(tput sgr0) and follow the
|
||||
instructions to launch an EC2 instance.
|
||||
|
||||
$(tput bold)Note: it's recommended to use a disk size of >=20GB.$(tput sgr0)"
|
||||
echo
|
||||
|
||||
read -p "Domain or IP of launched EC2 instance: " host
|
||||
|
||||
echo
|
||||
echo "$(tput bold)Copying configuration to ${host}...$(tput sgr0)"
|
||||
scp -i "${identityFile}" ./configuration.nix root@"${host}":/etc/nixos/configuration.nix
|
||||
|
||||
echo "$(tput bold)Building system...$(tput sgr0)"
|
||||
ssh -i "${identityFile}" root@"${host}" "nixos-rebuild switch --upgrade"
|
||||
Reference in New Issue
Block a user