aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJake Buchholz <tomalok@gmail.com>2019-06-03 21:19:59 -0700
committerMike Crute <mike@crute.us>2019-07-05 12:52:57 -0700
commit3ceb90d1ffdce6c878cb0afcdfe76a9f4cc4cc79 (patch)
treeb61b1097269adf20ac58c9f8e0914795c361356d
parent959968fa54455ca71276d5cef1308d61517576b4 (diff)
downloadtiny-ec2-bootstrap-3ceb90d1ffdce6c878cb0afcdfe76a9f4cc4cc79.tar.bz2
tiny-ec2-bootstrap-3ceb90d1ffdce6c878cb0afcdfe76a9f4cc4cc79.tar.xz
tiny-ec2-bootstrap-3ceb90d1ffdce6c878cb0afcdfe76a9f4cc4cc79.zip
make ec2 user configurable
-rw-r--r--README.md26
-rw-r--r--tiny-ec2-bootstrap8
2 files changed, 23 insertions, 11 deletions
diff --git a/README.md b/README.md
index 1e6e655..91df54c 100644
--- a/README.md
+++ b/README.md
@@ -9,8 +9,8 @@ and cloud platform support for small size and limited external dependencies.
9## Requirements 9## Requirements
10 10
11The most important feature of this bootstrapper is the very limited set of 11The most important feature of this bootstrapper is the very limited set of
12dependencies. In-fact this works with just busybox provided the wget applet is 12dependencies. In-fact, this works with just busybox -- provided the wget applet
13built-in. The only required dependencies are: 13is built-in. The only required dependencies are:
14 14
15- bash-like shell (e.g. bash, dash, ash) 15- bash-like shell (e.g. bash, dash, ash)
16- wget 16- wget
@@ -30,15 +30,23 @@ installing packages, and many other things. This bootstrap does not support
30those things. Instead it supports: 30those things. Instead it supports:
31 31
32- setting system hostname 32- setting system hostname
33- install user's configured SSH keys to the alpine user's authorized_keys file 33- installing the instance's SSH keys in the EC2 user's authorized_keys file
34- run any script-like user data (must start with #!) 34- running any script-like user data (must start with #!)
35- disable root and alpine password 35- disabling root and the EC2 user's password
36- resize root partition to available disk space 36- resizing root partition to available disk space
37 37
38These steps only run once. After the initial bootstrap the bootstrapper script 38These steps only run once. After the initial bootstrap the bootstrapper script
39is a no-op. To force the script to run again at boot time remove the file 39is a no-op. To force the script to run again at boot time remove the file
40`/var/lib/cloud/.bootstrap-complete` and reboot the instance. 40`/var/lib/cloud/.bootstrap-complete` and reboot the instance.
41 41
42The default EC2 user is `alpine`; this can be overriden with a
43`/etc/conf.d/tiny-ec2-bootstrap` containing...
44```
45EC2-USER="otheruser"
46```
47The EC2 user *must* already exist in the AMI -- `tiny-ec2-bootstrap` will
48**NOT** add the user automatically.
49
42## User Data 50## User Data
43 51
44User data is provided at instance boot time and can be any arbitrary string of 52User data is provided at instance boot time and can be any arbitrary string of
@@ -53,7 +61,7 @@ made at the point the script runs.
53 61
54## Assumptions 62## Assumptions
55 63
56- This was written for Alpine Linux and thus assumes that the login user is 64- This was written for Alpine Linux; use on other distributions has not been
57 called alpine. This could be configurable in the future but currently is not. 65tested.
58 66
59- The script is run by OpenRC 67- The script is run by OpenRC.
diff --git a/tiny-ec2-bootstrap b/tiny-ec2-bootstrap
index c03fcd3..83aeba7 100644
--- a/tiny-ec2-bootstrap
+++ b/tiny-ec2-bootstrap
@@ -64,13 +64,17 @@ start() {
64 # Don't bootstrap if the host has already been bootstrapped 64 # Don't bootstrap if the host has already been bootstrapped
65 [ -f "/var/lib/cloud/.bootstrap-complete" ] && return 0 65 [ -f "/var/lib/cloud/.bootstrap-complete" ] && return 0
66 66
67 # load configuration, set defaults
68 [ -f "/etc/conf.d/tiny-ec2-bootstrap" ] && . /etc/conf.d/tiny-ec2-bootstrap
69 EC2_USER=${EC2_USER:-alpine}
70
67 [ -d "/var/lib/cloud" ] || mkdir -p /var/lib/cloud 71 [ -d "/var/lib/cloud" ] || mkdir -p /var/lib/cloud
68 72
69 ebegin "Disabling root password"; _disable_password root; eend $? 73 ebegin "Disabling root password"; _disable_password root; eend $?
70 ebegin "Disabling alpine password"; _disable_password alpine; eend $? 74 ebegin "Disabling $EC2_USER password"; _disable_password "$EC2_USER"; eend $?
71 ebegin "Resizing root partition"; _resize_root_partition; eend $? 75 ebegin "Resizing root partition"; _resize_root_partition; eend $?
72 ebegin "Setting ec2 hostname"; _update_hostname; eend $? 76 ebegin "Setting ec2 hostname"; _update_hostname; eend $?
73 ebegin "Setting ec2 user ssh keys"; _set_ssh_keys "alpine"; eend $? 77 ebegin "Setting ec2 user ssh keys"; _set_ssh_keys "$EC2_USER"; eend $?
74 ebegin "Running ec2 user data script"; _run_userdata; eend $? 78 ebegin "Running ec2 user data script"; _run_userdata; eend $?
75 79
76 touch "/var/lib/cloud/.bootstrap-complete" 80 touch "/var/lib/cloud/.bootstrap-complete"