might work now
This commit is contained in:
@@ -1,5 +1,70 @@
|
||||
#!/bin/bash
|
||||
POSTFIX='/usr/sbin/postfix'
|
||||
MONITOR_INTERVAL=10 # seconds
|
||||
|
||||
echo "postfix starting..."
|
||||
exec 2>&1
|
||||
|
||||
exec /usr/lib/postfix/master
|
||||
if [[ ! -d /state/envdir ]]; then
|
||||
mkdir -p /state/envdir
|
||||
chown mastodon:mastodon /state/envdir
|
||||
fi
|
||||
|
||||
if [[ ! -e /state/envdir/WEB_DOMAIN ]]; then
|
||||
if [[ -n "$WEB_DOMAIN" ]]; then
|
||||
echo "$WEB_DOMAIN" > /state/envdir/WEB_DOMAIN
|
||||
else
|
||||
hostname --fqdn > /state/envdir/WEB_DOMAIN
|
||||
fi
|
||||
chown mastodon:mastodon /state/envdir/*
|
||||
fi
|
||||
|
||||
cat /etc/postfix/main.cf | grep -v '^myhostname' > /etc/postfix/main.new
|
||||
rm /etc/postfix/main.cf
|
||||
echo "myhostname = $(cat /state/envdir/WEB_DOMAIN)" >> /etc/postfix/main.cf
|
||||
echo "myorigin = $(cat /state/envdir/WEB_DOMAIN)" >> /etc/postfix/main.cf
|
||||
cat /etc/postfix/main.new >> /etc/postfix/main.cf
|
||||
rm /etc/postfix/main.new
|
||||
|
||||
running() {
|
||||
pkill -0 master
|
||||
}
|
||||
|
||||
start() {
|
||||
echo "postfix starting..."
|
||||
/etc/init.d/postfix start
|
||||
}
|
||||
|
||||
stop() {
|
||||
if running; then
|
||||
echo Stopping
|
||||
/etc/init.d/postfix stop
|
||||
fi
|
||||
}
|
||||
|
||||
reload() {
|
||||
echo Reloading
|
||||
/etc/init.d/postfix reload
|
||||
}
|
||||
|
||||
check() {
|
||||
echo Checking
|
||||
"$POSTFIX" check
|
||||
}
|
||||
|
||||
status() {
|
||||
"$POSTFIX" status
|
||||
}
|
||||
|
||||
|
||||
trap 'echo INT; stop; exit' INT
|
||||
trap 'echo QUIT; stop; exit' QUIT
|
||||
trap 'echo TERM; stop; exit' TERM
|
||||
trap 'echo STOP; stop' STOP
|
||||
trap 'echo HUP; reload' HUP
|
||||
trap 'echo USR1; check' USR1
|
||||
trap 'echo USR2; status' USR2
|
||||
|
||||
while :; do
|
||||
running || start
|
||||
sleep $MONITOR_INTERVAL
|
||||
done
|
||||
|
||||
@@ -2,7 +2,28 @@
|
||||
|
||||
echo "postgres starting..."
|
||||
|
||||
mkdir -p /state/db
|
||||
chown mastodon:mastodon /state/db
|
||||
exec chpst -u mastodon:mastodon /usr/lib/postgresql/bin/postmaster \
|
||||
-D /state/db 2>&1
|
||||
chown mastodon:mastodon /var/run/postgresql
|
||||
chown -R mastodon:mastodon /etc/postgresql
|
||||
|
||||
echo "local all all peer" > /etc/postgresql/10/main/pg_hba.conf
|
||||
echo "local all mastodon peer" >> /etc/postgresql/10/main/pg_hba.conf
|
||||
echo "local all root peer" >> /etc/postgresql/10/main/pg_hba.conf
|
||||
echo "host all all 127.0.0.0/8 trust" >> /etc/postgresql/10/main/pg_hba.conf
|
||||
|
||||
if [[ ! -d /state/db ]]; then
|
||||
mkdir -p /state/db/data
|
||||
rsync -a /var/lib/postgresql/10/main/ /state/db/data/
|
||||
cp -a /etc/postgresql/10/main/* /state/db/
|
||||
grep -v '^data_directory' /state/db/postgresql.conf |
|
||||
grep -v "^ssl" |
|
||||
grep -v "^stats_temp_directory" > /state/db/postgresql.new
|
||||
echo "data_directory = '/state/db/data'" >> /state/db/postgresql.new
|
||||
echo "stats_temp_directory = '/tmp'" >> /state/db/postgresql.new
|
||||
mv /state/db/postgresql.new /state/db/postgresql.conf
|
||||
chown -R mastodon:mastodon /state/db
|
||||
chmod go-rwx /state/db/data
|
||||
fi
|
||||
|
||||
exec \
|
||||
chpst -u mastodon:mastodon \
|
||||
/usr/lib/postgresql/10/bin/postmaster -D /state/db 2>&1
|
||||
|
||||
@@ -2,4 +2,11 @@
|
||||
|
||||
mkdir -p /state/redis
|
||||
chown mastodon:mastodon /state/redis
|
||||
exec chpst -u mastodon:mastodon /usr/bin/redis-server /etc/redis/redis.conf
|
||||
exec chpst -u mastodon:mastodon /usr/bin/redis-server - <<EOF
|
||||
daemonize no
|
||||
dir /state/redis
|
||||
save 900 1
|
||||
save 300 10
|
||||
save 60 10000
|
||||
EOF
|
||||
|
||||
|
||||
@@ -11,4 +11,4 @@ cd /mastodon/app
|
||||
exec \
|
||||
envdir /state/envdir \
|
||||
chpst -u mastodon:mastodon \
|
||||
bash -c "bundle exec sidekiq -c $SIDEKIQ_WORKERS -q default -q push -q pull -q mailers"
|
||||
bash -i -c "bundle exec sidekiq -c $SIDEKIQ_WORKERS -q default -q push -q pull -q mailers"
|
||||
|
||||
@@ -5,18 +5,43 @@ echo "mastodon-startup starting up..."
|
||||
|
||||
if [[ ! -d /state/envdir ]]; then
|
||||
mkdir -p /state/envdir
|
||||
chown mastodon:mastodon /state/envdir
|
||||
fi
|
||||
|
||||
if [[ ! -e /state/envdir/HOME ]]; then
|
||||
echo "/mastodon" > /state/envdir/HOME
|
||||
fi
|
||||
|
||||
if [[ ! -e /state/envdir/RAILS_ENV ]]; then
|
||||
echo "production" > /state/envdir/RAILS_ENV
|
||||
fi
|
||||
|
||||
chown mastodon:mastodon /state/envdir /state/envdir/*
|
||||
|
||||
cd /mastodon/app
|
||||
|
||||
if [ "$RUN_DB_MIGRATIONS" == "true" ]; then
|
||||
if [[ ! -e /state/envdir/OTP_SECRET ]]; then
|
||||
envdir /state/envdir \
|
||||
chpst -u mastodon:mastodon \
|
||||
bash -i -c "bundle exec rake secret > /state/envdir/OTP_SECRET"
|
||||
fi
|
||||
|
||||
if [[ ! -e /state/envdir/SECRET_KEY_BASE ]]; then
|
||||
envdir /state/envdir \
|
||||
chpst -u mastodon:mastodon \
|
||||
bash -i -c "bundle exec rake secret > /state/envdir/SECRET_KEY_BASE"
|
||||
fi
|
||||
|
||||
echo "
|
||||
create database mastodon_production;
|
||||
create user mastodon createdb;
|
||||
grant all privileges on database mastodon_production to mastodon;
|
||||
" | chpst -u postgres:postgres psql
|
||||
|
||||
if [[ -n "$RUN_DB_MIGRATIONS" ]]; then
|
||||
echo "Running database migrations..."
|
||||
envdir /state/envdir chpst -u mastodon:mastodon bash -c "bundle exec rake db:migrate"
|
||||
envdir /state/envdir \
|
||||
chpst -u mastodon:mastodon \
|
||||
bash -i -c "bundle exec rake db:migrate"
|
||||
fi
|
||||
|
||||
rm /state/.starting
|
||||
|
||||
@@ -8,4 +8,7 @@ done
|
||||
echo "streaming starting..."
|
||||
|
||||
cd /mastodon/app
|
||||
exec envdir /state/envdir chpst -u mastodon:mastodon bash -c "npm run start"
|
||||
exec \
|
||||
envdir /state/envdir \
|
||||
chpst -u mastodon:mastodon \
|
||||
bash -i -c "npm run start"
|
||||
|
||||
@@ -8,4 +8,7 @@ done
|
||||
echo "web starting..."
|
||||
|
||||
cd /mastodon/app
|
||||
exec envdir /state/envdir chpst -u mastodon:mastodon bash -c "bundle exec puma -C config/puma.rb"
|
||||
exec \
|
||||
envdir /state/envdir \
|
||||
chpst -u mastodon:mastodon \
|
||||
bash -i -c "bundle exec puma -C config/puma.rb"
|
||||
|
||||
Reference in New Issue
Block a user