Add support for AWS Lightsail (#125)

Co-authored-by: Eric Litak <elitak@gmail.com>
This commit is contained in:
Scott Stephens 2022-12-19 23:31:13 -06:00 committed by GitHub
parent 263470891c
commit e72cd89d99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 0 deletions

View File

@ -19,6 +19,7 @@ This script has successfully been tested on at least the follow hosting provider
* [Cockbox](https://cockbox.org)
* [Google Cloud Platform](https://cloud.google.com/)
* [Contabo](https://contabo.com)
* [AWS Lightsail](https://aws.amazon.com/lightsail/)
* [Windcloud](https://windcloud.de/)
* [Clouding.io](https://clouding.io)
@ -244,6 +245,13 @@ Tested on Cloud VPS. Contabo sets the hostname to something like `vmi######.cont
|------------|-----------------|-----------|----------|
|Ubuntu | 22.04 |**success**|2022-09-26|
### AWS Lightsail
Make sure to set `PROVIDER="lightsail"`.
Setting a root ssh key manually is not necessary, the key provided as part of the instance launch process will be used.
If you run into issues, debug using the most similar ec2 instance that is on the Nitro platform. Nitro platform instances have a serial console that allow you to troubleshoot boot issues, and Lightsail instances are just EC2 with a different pricing model and UI.
### Windcloud
Tested on vServer. The network configuration seems to be important so the same tweaks as for DigitalOcean are necessary (see above).
#### Tested on
@ -259,6 +267,7 @@ Requires the same static network settings that Digital Ocean does.
#### Tested on
|Distribution| Name | Status | test date|
|------------|-----------------|-----------|----------|
|Debian | 11.4 |**success**|2022-12-12|
|Ubuntu | 20.04 | success |2022-11-26|
### Clouding.io

25
nixos-infect Executable file → Normal file
View File

@ -7,6 +7,13 @@ set -e -o pipefail
makeConf() {
# Skip everything if main config already present
[[ -e /etc/nixos/configuration.nix ]] && return 0
# Lightsail config is not like the others
if [ "$PROVIDER" = "lightsail" ]; then
makeLightsailConf
return 0
fi
# NB <<"EOF" quotes / $ ` in heredocs, <<EOF does not
mkdir -p /etc/nixos
# Prevent grep for sending error code 1 (and halting execution) when no lines are selected : https://www.unix.com/man-page/posix/1P/grep
@ -76,6 +83,16 @@ EOF
[[ -n "$doNetConf" ]] && makeNetworkingConf || true
}
makeLightsailConf() {
mkdir -p /etc/nixos
cat > /etc/nixos/configuration.nix << EOF
{ config, pkgs, modulesPath, ... }:
{
imports = [ "\${modulesPath}/virtualisation/amazon-image.nix" ];
}
EOF
}
makeNetworkingConf() {
# XXX It'd be better if we used procfs for all this...
local IFS=$'\n'
@ -318,6 +335,12 @@ infect() {
# Reify resolv.conf
[[ -L /etc/resolv.conf ]] && mv -v /etc/resolv.conf /etc/resolv.conf.lnk && cat /etc/resolv.conf.lnk > /etc/resolv.conf
# Set label of root partition
if [ -n "$newrootfslabel" ]; then
echo "Setting label of $rootfsdev to $newrootfslabel"
e2label "$rootfsdev" "$newrootfslabel"
fi
# Stage the Nix coup d'état
touch /etc/NIXOS
echo etc/nixos >> /etc/NIXOS_LUSTRATE
@ -337,6 +360,8 @@ infect() {
/nix/var/nix/profiles/system/bin/switch-to-configuration boot
}
[ "$PROVIDER" = "digitalocean" ] && doNetConf=y # digitalocean requires detailed network config to be generated
[ "$PROVIDER" = "lightsail" ] && newrootfslabel="nixos"
if [[ "$PROVIDER" = "digitalocean" ]] || [[ "$PROVIDER" = "servarica" ]]; then
doNetConf=y # some providers require detailed network config to be generated
fi