This repository was archived by the owner on Feb 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustomize
More file actions
executable file
·131 lines (110 loc) · 3.64 KB
/
Copy pathcustomize
File metadata and controls
executable file
·131 lines (110 loc) · 3.64 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
#!/usr/bin/bash
PATH=/opt/local/gnu/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/usr/sbin
# Exit if any command fails
set -o errexit
MUNIN_PLUGINS="
apache_accesses
apache_processes
apache_volume
httpd_memory
passenger_status
passenger_memory
ps_httpd
ps_delayed_job
dj_queue
"
echo "* Activate munin plugins"
/opt/qutic/bin/munin-node-plugins ${MUNIN_PLUGINS}
echo "* Remove unused httpd config files"
HTTPD_CONF_RM="httpd-autoindex.conf
httpd-dav.conf
httpd-default.conf
httpd-info.conf
httpd-languages.conf
httpd-manual.conf
httpd-mpm.conf
httpd-multilang-errordoc.conf
httpd-ssl.conf
httpd-userdir.conf
httpd-vhosts.conf"
for CONF_RM in ${HTTPD_CONF_RM}; do
rm -f /opt/local/etc/httpd/${CONF_RM}
done
echo "* Setup ruby env"
echo "gem: --no-document " >> /opt/local/etc/gemrc
gem update --system
gem install bundler
gem install gemenv
gem install pkg-config
echo "* Setup ruby home"
groupadd -g 1100 ruby
useradd -m -s /usr/bin/bash -d /home/ruby -u 1100 -g ruby ruby
passwd -N ruby
passwd -d ruby
cat >> /home/ruby/.bashrc << EOF
source /home/ruby/www/shared/gems/bin/activate
EOF
cat >> /home/ruby/.bash_history << EOF
#`date +'%s'`
cd /home/ruby/www/current
EOF
mkdir -p /home/ruby/www/releases
mkdir -p /home/ruby/www/shared/config
mkdir -p /home/ruby/www/shared/content
mkdir -p /home/ruby/www/shared/log
mkdir -p /home/ruby/www/shared/system
cd /home/ruby/www/shared
/opt/local/bin/gemenv gems
mv /opt/local/var/tmp/activate /home/ruby/www/shared/gems/bin/activate
mv /opt/local/var/tmp/ruby /home/ruby/www/shared/gems/bin/ruby
chmod +x /home/ruby/www/shared/gems/bin/ruby
chown -R ruby:ruby /home/ruby/www
echo "* Setup spiped"
groupadd -g 120 spiped
useradd -m -s /usr/bin/false -d /nonexistent -u 120 -g spiped spiped
dd if=/dev/urandom bs=32 count=1 2>/dev/null | shasum -a 512 | awk '{print $1}' | tr -d '\n' > /etc/ssh/spiped.key
chmod 0640 /etc/ssh/spiped.key
chown root:spiped /etc/ssh/spiped.key
svccfg delete svc:/pkgsrc/spiped:default
# Configuring image specific packages
echo "* Configuring image specific packages.";
mkdir -p /var/log/httpd/old
mkdir -p /opt/local/etc/httpd/ssl || true
chmod 0640 /opt/local/etc/httpd/ssl
ln -nfs /opt/local/etc/httpd/ssl /opt/local/etc/httpd/tls
echo "* Setup proxysql";
pkg_add https://download.qutic.com/extras/proxysql-1.4.7.tgz || true
mkdir -p /opt/local/var/proxysql
groupadd -g 130 proxysql
useradd -m -s /usr/bin/false -d /opt/local/var/proxysql -u 130 -g proxysql proxysql
chown proxysql:proxysql /opt/local/var/proxysql/
mv /opt/local/etc/proxysql.cnf /opt/local/etc/proxysql.cnf.bak || true
mv /opt/local/var/tmp/proxysql.cnf /opt/local/etc/proxysql.cnf
chmod 0640 /opt/local/etc/proxysql.cnf
chown root:proxysql /opt/local/etc/proxysql.cnf
mv /opt/local/var/tmp/proxysql.xml /opt/local/lib/svc/manifest/proxysql.xml
svccfg import /opt/local/lib/svc/manifest/proxysql.xml
ln -nfs /var/svc/log/pkgsrc-proxysql:default.log /var/log/proxysql_log
# zabbix proxysql
pip3.7 install mysqlclient
echo "* Fix passenger";
echo "export PASSENGER_INSTANCE_REGISTRY_DIR=/var/tmp" >> /root/.bashrc
# fix wrong passenger pkgsrc build 2017Q4 for ruby 2.4
ln -nfs /opt/local/lib/ruby/vendor_ruby/2.5.0 /opt/local/lib/ruby/vendor_ruby/2.2.0
echo "* Import ruby process watcher";
svccfg import /opt/qutic/lib/svc/manifest/rbpswatch.xml
# svcadm enable rbpswatch
echo "* Add plugin config";
cat >> /opt/local/etc/munin/plugin-conf.d/dj_queue << EOF
[dj_queue]
env.PATH /usr/local/sbin:/usr/local/bin:/opt/local/sbin:/opt/local/bin:/usr/sbin:/usr/bin:/sbin
user ruby
EOF
# Clean up
echo "* Cleaning up."
#pkgin -y remove gmake
#pkgin -y remove gcc7
rm /root/customize
rm -rf /opt/local/var/tmp
# Prepare image for provisioning
sm-prepare-image -y