This repository was archived by the owner on Nov 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path3485-shell.quixoftic.com.sh
More file actions
executable file
·161 lines (128 loc) · 5.51 KB
/
3485-shell.quixoftic.com.sh
File metadata and controls
executable file
·161 lines (128 loc) · 5.51 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/bash
#
# Copyright (C) 2011 by Quixoftic, LLC <src@quixoftic.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# This Linode StackScript configures the Linode to run as
# shell.quixoftic.com, a unique host.
HOSTNAME=shell
DOMAINNAME=quixoftic.com
CONFIG=quixoftic-meta-shell-config
# <UDF name="mailmanpasswd" label="Initial password for the mailman mailing list."/>
# <UDF name="qxallpasswd" label="Initial password for the quixoftic-all mailing list."/>
# <UDF name="debian_mirror" label="Debian mirror to use for install" default="ftp.us.debian.org"/>
# <UDF name="username" label="User account to create (will be added to sudo, adm groups)."/>
# <UDF name="userfullname" label="First and last name of user."/>
# <UDF name="passwd" label="*Encrypted* password."/>
# <UDF name="sshkey" label="ssh public key for above account"/>
# <UDF name="notifyemail" label="Send email to this address when installation is complete (optional)."/>
source <ssinclude StackScriptID=3480>
#
# Script begins here.
#
set -e
set -E
LOGFILE=~root/stackscript.log
enable_logging $LOGFILE
# Secure SSH first to shorten the brute-force window.
secure_ssh
# Upgrade to sid and install some key packages.
upgrade_to_sid $DEBIAN_MIRROR
apt_install etckeeper
apt_install heirloom-mailx
# Set the FQDN, and make sure that the resolver is updated by
# restarting the eth0 interface. This is overkill, but it's portable,
# as reloading resolvconf doesn't work reliably on Debian stable.
apt_install resolvconf
resolvconf_set_domainname $DOMAINNAME
restart_interface eth0
etckeeper_commit "Set domain name to $DOMAINNAME."
set_hostname $HOSTNAME
etckeeper_commit "Set hostname to $HOSTNAME."
# Mail setup (null client config).
set_mailname $DOMAINNAME
etckeeper_commit "Set mailname to $DOMAINNAME."
install_postfix_null_client $DOMAINNAME
etckeeper_commit "postfix: null client config for domain $DOMAINNAME."
# At this point it's possible to send email.
[ -n "$NOTIFYEMAIL" ] && trap_with_failure_email "Linode VPS $HOSTNAME install FAILED." "$NOTIFYEMAIL" "$LOGFILE"
# All quixoftic.com systems use UTC.
set_timezone_to_utc
etckeeper_commit "Set timezone to UTC."
# All Quixoftic hosts require a separate /var/log device on /dev/xvdc,
# and encrypted swap on /dev/xvdb. This host also requires an
# /dev/xvdd device for an encrypted /home filesystem. Bail out if the
# Linode config profile didn't include them.
check_device /dev/xvdb
check_device /dev/xvdc
check_device /dev/xvdd
# Install Quixoftic shell meta-config package.
add_quixoftic_apt_sources quixoftic-temp
etckeeper_commit "Add temporary Quixoftic apt sources and archive keyring."
install_quixoftic_meta_package $CONFIG
remove_quixoftic_apt_sources quixoftic-temp
etckeeper_commit "Remove temporary Quixoftic apt sources."
# Move /var/log to a separate filesystem on /dev/xvdc (required for
# all Quixoftic hosts).
copy_fs /var/log /dev/xvdc ext3 varlog
# Mailing list creation.
echo "Creating the required mailman administrative mailing list."
newlist -q mailman postmaster@quixoftic.com "$MAILMANPASSWD"
echo "Creating the quixoftic-all employee mailing list."
newlist -q quixoftic-all postmaster@quixoftic.com "$QXALLPASSWD"
/etc/init.d/mailman restart
# Create user, add to admin groups.
apt_install sudo
add_user $USERNAME "$USERFULLNAME" $PASSWD
add_user_to_group $USERNAME sudo
add_user_to_group $USERNAME adm
etckeeper_commit "Add user $USERNAME (groups: sudo, adm)."
# Install user's ssh public key.
install_ssh_pubkey $USERNAME "$SSHKEY"
# All Quixoftic hosts use the distro kernel and use pv-grub. Do this
# step late in the process, because the apt grub probes are slow.
apt_install linux-image-amd64
install_grub
# Cleanup.
apt_clean
if [ -n "$NOTIFYEMAIL" ] ; then
mailx -s "Linode VPS $HOSTNAME install successful." "$NOTIFYEMAIL" <<EOF
Your install was successful!
This is a special configuration. Before rebooting, you must
perform the following steps manually:
- install the imap.quixoftic.com SSL key.
- install the mx1.quixoftic.com SSL key.
- install any required DKIM keys.
You should then reboot the host immediately with a pv-grub config
profile. Don't forget to disable the 'Xenify Distro' option!
EOF
fi
echo "
***************
Your install was successful!
This is a special configuration. Before rebooting, you must
perform the following steps manually:
- install the imap.quixoftic.com SSL key.
- install the mx1.quixoftic.com SSL key.
- install any required DKIM keys.
You should then reboot the host immediately with a pv-grub config
profile. Don't forget to disable the 'Xenify Distro' option!
***************
"
exit 0