Skip to content

Commit

Permalink
Move most of the scripts to the scripts directory (#237)
Browse files Browse the repository at this point in the history
It makes docker image and repository cleaner
  • Loading branch information
CyberDem0n committed May 29, 2018
1 parent d9a6619 commit 915a9d1
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 17 deletions.
4 changes: 3 additions & 1 deletion postgres-appliance/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ RUN mkdir -p /var/log/supervisor \
&& echo "export PAGER='pspg -bX --no-mouse'" >> /etc/bash.bashrc \
&& echo "source /etc/motd" >> /root/.bashrc

ADD scm-source.json configure_spilo.py launch.sh postgres_backup.sh patroni_wait.sh post_init.sh _zmon_schema.dump callback_*.py basebackup.sh wale_restore_command.sh wal-e-wal-fetch.sh create_user_functions.sql bootstrap /
ADD scripts bootstrap /scripts/

ADD scm-source.json launch.sh /

CMD ["/bin/sh", "/launch.sh"]
8 changes: 4 additions & 4 deletions postgres-appliance/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ chown -R postgres:postgres "$PGROOT"

if [ "$DEMO" = "true" ]; then
sed -i '/motd/d' /root/.bashrc
python3 /configure_spilo.py patroni patronictl certificate pam-oauth2
python3 /scripts/configure_spilo.py patroni patronictl certificate pam-oauth2
(
su postgres -c 'env -i PGAPPNAME="pgq ticker" /patroni_wait.sh --role master -- /usr/bin/pgqd /home/postgres/pgq_ticker.ini'
su postgres -c 'env -i PGAPPNAME="pgq ticker" /scripts/patroni_wait.sh --role master -- /usr/bin/pgqd /home/postgres/pgq_ticker.ini'
) &
exec su postgres -c "PATH=$PATH exec patroni /home/postgres/postgres.yml"
else
if python3 /configure_spilo.py all; then
if python3 /scripts/configure_spilo.py all; then
(
su postgres -c "PATH=$PATH /patroni_wait.sh -t 3600 -- /postgres_backup.sh $WALE_ENV_DIR $PGDATA"
su postgres -c "PATH=$PATH /scripts/patroni_wait.sh -t 3600 -- /postgres_backup.sh $WALE_ENV_DIR $PGDATA"
) &
fi
exec supervisord --configuration=/etc/supervisor/supervisord.conf --nodaemon
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def deep_update(a, b):
TEMPLATE = \
'''
bootstrap:
post_init: /post_init.sh "{{HUMAN_ROLE}}"
post_init: /scripts/post_init.sh "{{HUMAN_ROLE}}"
dcs:
ttl: 30
loop_wait: &loop_wait 10
Expand Down Expand Up @@ -148,9 +148,9 @@ def deep_update(a, b):
{{#CLONE_WITH_WALE}}
method: clone_with_wale
clone_with_wale:
command: python3 /clone_with_s3.py --envdir "{{CLONE_WALE_ENV_DIR}}" --recovery-target-time="{{CLONE_TARGET_TIME}}"
command: python3 /scripts/clone_with_s3.py --envdir "{{CLONE_WALE_ENV_DIR}}" --recovery-target-time="{{CLONE_TARGET_TIME}}"
recovery_conf:
restore_command: envdir "{{CLONE_WALE_ENV_DIR}}" /wale_restore_command.sh "%f" "%p"
restore_command: envdir "{{CLONE_WALE_ENV_DIR}}" /scripts/wale_restore_command.sh "%f" "%p"
recovery_target_timeline: latest
{{#USE_PAUSE_AT_RECOVERY_TARGET}}
pause_at_recovery_target: false
Expand All @@ -168,7 +168,7 @@ def deep_update(a, b):
{{#CLONE_WITH_BASEBACKUP}}
method: clone_with_basebackup
clone_with_basebackup:
command: python3 /clone_with_basebackup.py --pgpass={{CLONE_PGPASS}} --host={{CLONE_HOST}} --port={{CLONE_PORT}} --user="{{CLONE_USER}}"
command: python3 /scripts/clone_with_basebackup.py --pgpass={{CLONE_PGPASS}} --host={{CLONE_HOST}} --port={{CLONE_PORT}} --user="{{CLONE_USER}}"
{{/CLONE_WITH_BASEBACKUP}}
initdb:
- encoding: UTF8
Expand Down Expand Up @@ -227,7 +227,7 @@ def deep_update(a, b):
{{#USE_WALE}}
recovery_conf:
restore_command: envdir "{{WALE_ENV_DIR}}" /wale_restore_command.sh "%f" "%p"
restore_command: envdir "{{WALE_ENV_DIR}}" /scripts/wale_restore_command.sh "%f" "%p"
{{/USE_WALE}}
authentication:
superuser:
Expand Down Expand Up @@ -255,7 +255,7 @@ def deep_update(a, b):
retries: 2
no_master: 1
basebackup_fast_xlog:
command: /basebackup.sh
command: /scripts/basebackup.sh
retries: 2
{{/USE_WALE}}
'''
Expand Down Expand Up @@ -400,7 +400,8 @@ def get_placeholders(provider):
if provider == PROVIDER_AWS:
if not USE_KUBERNETES: # AWS specific callback to tag the instances with roles
if placeholders.get('EIP_ALLOCATION'):
placeholders['CALLBACK_SCRIPT'] = 'python3 /callback_aws.py {0}'.format(placeholders['EIP_ALLOCATION'])
placeholders['CALLBACK_SCRIPT'] = 'python3 /scripts/callback_aws.py {0}'. \
format(placeholders['EIP_ALLOCATION'])
else:
placeholders['CALLBACK_SCRIPT'] = 'patroni_aws'

Expand All @@ -410,9 +411,9 @@ def get_placeholders(provider):
if USE_KUBERNETES:
if placeholders.get('DCS_ENABLE_KUBERNETES_API'):
if placeholders.get('KUBERNETES_USE_CONFIGMAPS'):
placeholders['CALLBACK_SCRIPT'] = 'python3 /callback_endpoint.py'
placeholders['CALLBACK_SCRIPT'] = 'python3 /scripts/callback_endpoint.py'
else:
placeholders['CALLBACK_SCRIPT'] = 'python3 /callback_role.py'
placeholders['CALLBACK_SCRIPT'] = 'python3 /scripts/callback_role.py'

placeholders.setdefault('postgresql', {})
placeholders['postgresql'].setdefault('parameters', {})
Expand Down Expand Up @@ -580,7 +581,7 @@ def write_crontab(placeholders, overwrite):
return logging.warning('Cron is already configured. (Use option --force to overwrite cron)')

lines = ['PATH={PATH}'.format(**placeholders)]
lines += ['{BACKUP_SCHEDULE} /postgres_backup.sh "{WALE_ENV_DIR}" "{PGDATA}" "{BACKUP_NUM_TO_RETAIN}"'
lines += ['{BACKUP_SCHEDULE} /scripts/postgres_backup.sh "{WALE_ENV_DIR}" "{PGDATA}" "{BACKUP_NUM_TO_RETAIN}"'
.format(**placeholders)]

lines += yaml.load(placeholders['CRONTAB'])
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

cd "$(dirname "${BASH_SOURCE[0]}")"

(echo "DO \$\$
BEGIN
PERFORM * FROM pg_catalog.pg_authid WHERE rolname = 'admin';
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ if [[ -z $WALE_S3_PREFIX ]]; then # non AWS environment?
exec wal-e wal-fetch -p $POOL_SIZE "${wal_filename}" "${wal_destination}"
fi
else
exec /wal-e-wal-fetch.sh --aws-instance-profile wal-fetch -p $POOL_SIZE "${wal_filename}" "${wal_destination}"
exec /scripts/wal-e-wal-fetch.sh --aws-instance-profile wal-fetch -p $POOL_SIZE "${wal_filename}" "${wal_destination}"
fi
2 changes: 1 addition & 1 deletion postgres-appliance/supervisor/conf.d/pgq.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
priority=999
directory=/
user=postgres
command=env -i PGAPPNAME="pgq ticker" /patroni_wait.sh --role master -- /usr/bin/pgqd /home/postgres/pgq_ticker.ini
command=env -i PGAPPNAME="pgq ticker" /scripts/patroni_wait.sh --role master -- /usr/bin/pgqd /home/postgres/pgq_ticker.ini
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
redirect_stderr=true
Expand Down

0 comments on commit 915a9d1

Please sign in to comment.