summaryrefslogtreecommitdiffstats
path: root/hosts/erp1
diff options
context:
space:
mode:
Diffstat (limited to 'hosts/erp1')
-rw-r--r--hosts/erp1/postinst135
1 files changed, 135 insertions, 0 deletions
diff --git a/hosts/erp1/postinst b/hosts/erp1/postinst
new file mode 100644
index 0000000..aecb4f1
--- /dev/null
+++ b/hosts/erp1/postinst
@@ -0,0 +1,135 @@
+#!/bin/sh
+
+# Add "deb-src" line and backports.
+info 'Configuring APT'
+cat >"${target}/etc/apt/sources.list" <<-EOF
+ deb http://httpredir.debian.org/debian jessie main
+ deb-src http://httpredir.debian.org/debian jessie main
+ EOF
+cat >"${target}/etc/apt/sources.list.d/jessie-backports.list" <<-EOF
+ deb http://httpredir.debian.org/debian jessie-backports main
+ deb-src http://httpredir.debian.org/debian jessie-backports main
+ EOF
+in_target apt-get update || return 1
+
+# Purge systemd.
+info 'Purging systemd'
+in_target apt-get -q -y purge libpam-systemd systemd || return 1
+in_target apt-get -q -y --purge autoremove || return 1
+
+# Disable services.
+printf '#!/bin/sh\n\nexit 101\n' >"${target}/usr/sbin/policy-rc.d"
+chmod a+x "${target}/usr/sbin/policy-rc.d"
+
+# Install LedgerSMB.
+info 'Installing LedgerSMB'
+cat >"${target}/etc/apt/sources.list.d/ledgersmb.list" <<-EOF
+ deb https://apt.ledgersmb.org/ jessie main
+ deb-src https://apt.ledgersmb.org/ jessie main
+ EOF
+wget -O - https://apt.ledgersmb.org/apt-ledgersmb-org_public-key.asc | \
+ in_target apt-key add - || return 1
+in_target apt-get update || return 1
+i=0; while [ ${i} -lt 3 ]; do i=$((${i} + 1))
+ DEBIAN_FRONTEND=noninteractive in_target apt-get -q -y install \
+ ledgersmb && break
+done || return 1
+# Ugly hack:
+mv "${target}/etc/rc.local" "${target}/etc/rc.local.orig"
+cat >"${target}/etc/rc.local" <<-EOF
+ #!/bin/sh -e
+ pg_dropcluster --stop 9.4 main
+ pg_createcluster --locale en_US.UTF-8 --start 9.4 main
+ /usr/share/ledgersmb/tools/config-lsmb-db-user.sh ledgersmb LEDGERSMBINITIAL
+ sudo -u postgres createuser -d odoo
+ mv /etc/rc.local.orig /etc/rc.local
+ EOF
+chmod a+x "${target}/etc/rc.local"
+# Another ugly hack: allow non-localhost connections.
+sed -i '29,31s/^ / #/' "${target}/etc/apache2/conf-available/ledgersmb.conf"
+
+# Install Odoo.
+info 'Installing Odoo'
+cat >"${target}/etc/apt/sources.list.d/odoo.list" <<-EOF
+ deb http://nightly.odoo.com/9.0/nightly/deb/ ./
+ deb-src http://nightly.odoo.com/9.0/nightly/deb/ ./
+ EOF
+wget -O - https://nightly.odoo.com/odoo.key | in_target apt-key add - || \
+ return 1
+in_target apt-get update || return 1
+i=0; while [ ${i} -lt 3 ]; do i=$((${i} + 1))
+ DEBIAN_FRONTEND=noninteractive in_target apt-get -q -y install \
+ odoo && break
+done || return 1
+
+# Enable services.
+rm -f "${target}/usr/sbin/policy-rc.d"
+
+# Remove packages from APT cache.
+in_target apt-get clean || return 1
+
+# Update initramfs.
+info 'Updating initramfs'
+in_target update-initramfs -u
+
+# Configure network interfaces.
+cat >"${target}/etc/network/interfaces" <<-EOF
+# This file describes the network interfaces available on your system
+# and how to activate them. For more information, see interfaces(5).
+
+# The loopback network interface
+auto lo
+iface lo inet loopback
+
+# The primary network interface
+auto eth0
+allow-hotplug eth0
+iface eth0 inet dhcp
+EOF
+
+# Use temporary configuation SSH key.
+install -d -o 1000 -g 1000 -m 0700 "${target}/home/user/.ssh" || return 1
+cat >"${target}/home/user/.ssh/id_rsa" <<-EOF
+ -----BEGIN RSA PRIVATE KEY-----
+ MIICXAIBAAKBgQCzAF0zqeS2X0TuVOIxqMec3lMzZy/MHQswPP+BQkmc2D3YVb2x
+ px1YAAweQnfZ27pGJkDztStOtMQJeaOsnAVdm2NSe+hEdaKAOxf9p6t+F930HM/w
+ 1wkm1ddlsnCaaCipzGVOM77Q/brEItWvuq8G0+/fgN1o4pZzl4Bub/4D4QIDAQAB
+ AoGAS+wKnAAiXuv3m7LrIa75w2JVHcdVcZicB0DICnYoLNtXF+v+AlzkSE/009zT
+ YtccoeZVxEiCbuajA3XRY0PlzgGHTbsGn1BWqI9cjdXTiotnjzOH8zr3JiMZMWwf
+ hqwbtleP+yruNPHMxQ8dKVXv875NKJW+aArmQWtjeMOy/vECQQDdsvPJ4bUu8M7/
+ MXqGtz8CJbrRp+ZMKUw0WuwSwTfHRs/Jp27mWf5+t/u+RN8WK/RRD8FHvz4azLhr
+ sNUFiE69AkEAzrI/DFBFOM5mUECujs2UvCCeWZiAi9QoJ7kDrrAkcG+hMalpNUU3
+ SUZ76stBUk3hZNpc82aq0a0o8ac0VrBd9QJAB3nbYrlrxLN2J4Dhot1XEJl5HUzO
+ JU9XNITEZTWCzgODSkeNI9NxE5DcumPUKgk9aeZgHC1EyN6ScX87D76y+QJAL8DE
+ ii69X1toDeBzs7BRTYlnrCFsiWGRiWPYMvKk6IkRv6x5DwKXvEkZdexRghdWHHvK
+ f71Xd6u+yt2rXN/QRQJBALv6SwbokdXp5qKJV48QG452dSOT7FQEINnCsIeNUKP6
+ 9YyaZxqLia6pEbEKTSRdztXaMqRsrmOG8E084sFg8DQ=
+ -----END RSA PRIVATE KEY-----
+ EOF
+in_target chown user:user '/home/user/.ssh/id_rsa'
+in_target chmod 0600 '/home/user/.ssh/id_rsa'
+
+# Set up SSH known hosts.
+cat >"${target}/home/user/.ssh/known_hosts" <<-EOF
+ |1|fypb7kn7NH0fqHGj9Xs/rdpO71s=|SCtg2BdMNB9zL5bAPYkJy1uiNSM= ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCXcG5BuZi4947D9WqY1L6CzaH4Qjw7YA7Dja+09y0nZjLVDd1saZCPkTjo1PEHxVCvSHvc0VmRqIZ2wUGtuqIlgGPMphCPAtdHN63YcNXqIhjEygLsaSZgy1Qz33YQF+YSANbeZQ4vnqiYr3C1IA7Cw4km/0s1BvP3t9yJf/iYODZqjVqUhqB4hzXJcBZHrgnM4LmPD4NH81fCqpwfRviNQNFAqd/aT1YTvgdn46HTVz7dV8ahW6SLXBTJZvO9dLAAKOPPZwuluaRphBqjPLC83zsihQ884SAH+AKcpN1ne73UZUuA1Gyk3HW+a/ngbzm1nmoeC0Sm1nNlTvC4WrLD
+ |1|z7it+otnWcn/98YKdeaBCXl+ug8=|NFRpdQZBMTAuWbUDAqXLptFR5Ao= ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCXcG5BuZi4947D9WqY1L6CzaH4Qjw7YA7Dja+09y0nZjLVDd1saZCPkTjo1PEHxVCvSHvc0VmRqIZ2wUGtuqIlgGPMphCPAtdHN63YcNXqIhjEygLsaSZgy1Qz33YQF+YSANbeZQ4vnqiYr3C1IA7Cw4km/0s1BvP3t9yJf/iYODZqjVqUhqB4hzXJcBZHrgnM4LmPD4NH81fCqpwfRviNQNFAqd/aT1YTvgdn46HTVz7dV8ahW6SLXBTJZvO9dLAAKOPPZwuluaRphBqjPLC83zsihQ884SAH+AKcpN1ne73UZUuA1Gyk3HW+a/ngbzm1nmoeC0Sm1nNlTvC4WrLD
+ EOF
+in_target chown user:user '/home/user/.ssh/known_hosts'
+in_target chmod 0600 '/home/user/.ssh/known_hosts'
+
+# Bootstrap vcsh and mr.
+info 'Bootstrapping dotfiles'
+rm -f "${target}/home/user/.profile" "${target}/home/user/.bashrc" \
+ "${target}/home/user/.bash_logout"
+in_target sudo -u user vcsh clone ssh://git@git.pehjota.net/dotfiles/mr.git mr \
+ || return 1
+in_target sudo -u user mr update || return 1
+
+# Generate target's SSH keypair.
+#rm -f "${target}/home/user/.ssh/id_rsa" "${target}/home/user/.ssh/id_rsa.pub" \
+# || return 1
+#in_target ssh-keygen -b 4096 -C user@erp1 -t rsa -f /home/user/.ssh/id_rsa \
+# </dev/null || return 1
+#cp "${target}/home/user/.ssh/id_rsa.pub" 'user@erp1.pub' || return 1
+
+return 0