mbligh | 88e12a1 | 2009-03-09 21:48:33 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # steps to take following a release of new code to keep things working. |
| 4 | # |
| 5 | # the following scripts may be created to customize behavior: |
| 6 | # |
| 7 | # site_utils/site_sync_code |
| 8 | # |
| 9 | # - pull code from a source repository |
| 10 | # |
| 11 | # site_utils/site_install_cli |
| 12 | # |
| 13 | # - install or update client code (new "atest" build?) |
| 14 | # |
| 15 | # site_utils/site_restart_apache |
| 16 | # |
| 17 | # - suid helper or similar? |
| 18 | # |
| 19 | # site_utils/site_restart_final |
| 20 | # |
| 21 | # - any finishing touches you may require. |
| 22 | |
| 23 | # --- |
| 24 | |
| 25 | INIT_SCR=/etc/init.d/autotest |
| 26 | |
| 27 | # --- |
| 28 | |
| 29 | print_status() { |
| 30 | STATUS=$1 |
| 31 | |
| 32 | echo "--- $STATUS" |
| 33 | } |
| 34 | |
| 35 | fatal() { |
| 36 | echo "*** Fatal error. Giving up." |
| 37 | exit 1 |
| 38 | } |
| 39 | |
| 40 | # --- |
| 41 | |
| 42 | MY_DIR=`dirname $0` |
| 43 | |
| 44 | if (! test -f $INIT_SCR) |
| 45 | then |
| 46 | echo "Error: $INIT_SCR must be installed." |
| 47 | exit 1 |
| 48 | fi |
| 49 | |
| 50 | BECOME_USER=`grep ^BECOME_USER= $INIT_SCR` |
| 51 | |
| 52 | if (test "$BECOME_USER" == "") |
| 53 | then |
| 54 | echo "Error: BECOME_USER not defined in $INIT_SCR" |
| 55 | exit 1 |
| 56 | fi |
| 57 | |
| 58 | BASE_DIR=`grep ^BASE_DIR= $INIT_SCR` |
| 59 | |
| 60 | if (test "$BASE_DIR" == "") |
| 61 | then |
| 62 | echo "Error: BASE_DIR not defined in $INIT_SCR" |
| 63 | exit 1 |
| 64 | fi |
| 65 | |
| 66 | eval $BECOME_USER |
| 67 | eval $BASE_DIR |
| 68 | |
| 69 | # --- stop autotest persistent code |
| 70 | |
| 71 | print_status "Stopping autotest persistent code" |
| 72 | $INIT_SCR stop |
| 73 | |
| 74 | # --- sync code (site-specific) |
| 75 | |
| 76 | if (test -x $BASE_DIR/site_utils/site_sync_code) |
| 77 | then |
| 78 | print_status "Syncing code" |
| 79 | su $BECOME_USER -c $BASE_DIR/site_utils/site_sync_code || exit 1 |
| 80 | fi |
| 81 | |
mbligh | cc1b999 | 2009-03-25 19:28:06 +0000 | [diff] [blame] | 82 | # --- run database migrations |
| 83 | |
| 84 | # - AFE |
| 85 | |
| 86 | print_status "Running AFE migrations" |
| 87 | ( cd $BASE_DIR/frontend && |
| 88 | su $BECOME_USER -c "python ../database/migrate.py \ |
| 89 | --database=AUTOTEST_WEB safesync" |
| 90 | su $BECOME_USER -c "python manage.py syncdb --noinput" |
| 91 | su $BECOME_USER -c "python manage.py syncdb --noinput" |
| 92 | ) |
| 93 | |
| 94 | # - TKO |
| 95 | |
| 96 | print_status "Running TKO migrations" |
| 97 | ( cd $BASE_DIR/tko && |
| 98 | su $BECOME_USER -c "python ../database/migrate.py \ |
| 99 | --database=TKO safesync" |
| 100 | ) |
| 101 | |
| 102 | # - SITE_DB |
| 103 | |
| 104 | print_status "Running site_db migrations" |
| 105 | ( cd $BASE_DIR/site_db && |
| 106 | su $BECOME_USER -c "python ../database/migrate.py \ |
| 107 | --database=TKO safesync" |
| 108 | ) |
| 109 | |
mbligh | 88e12a1 | 2009-03-09 21:48:33 +0000 | [diff] [blame] | 110 | # --- compile AfeClient |
| 111 | |
| 112 | print_status "Compiling AfeClient" |
| 113 | ( cd $BASE_DIR/frontend/client && |
| 114 | su $BECOME_USER -c ./AfeClient-compile ) || fatal |
| 115 | |
| 116 | # --- compile TkoClient |
| 117 | |
| 118 | print_status "Compiling TkoClient" |
| 119 | ( cd $BASE_DIR/frontend/client && |
| 120 | su $BECOME_USER -c ./TkoClient-compile ) || fatal |
| 121 | |
| 122 | # --- fix gwt permissions |
| 123 | |
| 124 | print_status "Fixing permissions" |
| 125 | ( cd $BASE_DIR/frontend/client && |
| 126 | find | xargs chmod o+r && |
| 127 | find -type d | xargs chmod o+rx ) || fatal |
| 128 | |
| 129 | # --- update cli repository (site-specific) |
| 130 | |
| 131 | if (test -x $BASE_DIR/site_utils/site_install_cli) |
| 132 | then |
| 133 | print_status "Updating cli repository" |
| 134 | su $BECOME_USER -c $BASE_DIR/site_utils/site_install_cli || fatal |
| 135 | fi |
| 136 | |
| 137 | # --- restart autotest persistent code |
| 138 | |
| 139 | print_status "Restarting autotest persistent code" |
| 140 | $INIT_SCR start || fatal |
| 141 | |
| 142 | # --- possibly restart Apache (site-specific) |
| 143 | |
| 144 | if (test -x $BASE_DIR/site_utils/site_restart_apache) |
| 145 | then |
| 146 | print_status "Restarting Apache" |
| 147 | su $BECOME_USER -c $BASE_DIR/site_utils/site_restart_apache || fatal |
| 148 | fi |
| 149 | |
| 150 | # --- do any site-specific finalization |
| 151 | |
| 152 | if (test -x $BASE_DIR/site_utils/site_restart_final) |
| 153 | then |
| 154 | print_status "Finalizing release" |
| 155 | su $BECOME_USER -c $BASE_DIR/site_utils/site_restart_final || fatal |
| 156 | fi |
| 157 | |