-
Notifications
You must be signed in to change notification settings - Fork 0
/
aboot
74 lines (54 loc) · 1.3 KB
/
aboot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#! /bin/bash
# this script runs only on the very first boot
# will be visible at
# curl http://169.254.169.254/latest/user-data
# will run from /var/lib/cloud/instances/instance-id/
# output will go to /var/log/cloud-init-output.log
exec > /tmp/aboot.out 2>&1
set -x
date
if [ "x$ABOOT_HOSTNAME" != "x" ]
then
echo "$ABOOT_HOSTNAME" > /etc/hostname
hostname $ABOOT_HOSTNAME
fi
adduser --disabled-password --gecos "$ABOOT_GECOS" $ABOOT_USER
addgroup sudo2
adduser $ABOOT_USER sudo2
echo '%sudo2 ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/99-sudo2
s=/home/$ABOOT_USER/.ssh
mkdir -m 700 -p $s
cp /home/ubuntu/.ssh/authorized_keys $s/
chown -R $ABOOT_USER:$ABOOT_USER $s
chmod 700 $s
export DEBIAN_FRONTEND=noninteractive
apt-get update -y
apt-get upgrade -y
date
apt-get install -y \
emacs-nox \
git \
build-essential \
python3-pip \
pwgen \
apache2 \
libapache2-mod-php \
apt-file \
pkg-config \
libreadline-dev \
php-xdebug \
mlocate
a2enmod php7.3
a2enmod headers
a2enmod rewrite
a2enmod ssl
echo "ServerName localhost" >> /etc/apache2/apache2.conf
if [ "x$ABOOT_EBS_UUID" != "x" ]
then
mdir=/a
mkdir -p ${mdir}
chown $ABOOT_USER ${mdir}
echo "UUID=\"${ABOOT_EBS_UUID}\" ${mdir} xfs defaults,nofail 0 2" >> /etc/fstab
(mount ${mdir} ; chown $ABOOT_USER ${mdir}) &
fi
echo done