From: Florent Bruneau Date: Mon, 1 Mar 2010 21:02:07 +0000 (+0100) Subject: Replace copy_tables.php by a shell script (database alteration require admin privileges) X-Git-Tag: xorg/1.0.0~332^2~132 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=aa1f260a73063805648c82a2198499f161966e31;p=platal.git Replace copy_tables.php by a shell script (database alteration require admin privileges) Signed-off-by: Florent Bruneau --- diff --git a/upgrade/account/copy_tables.php b/upgrade/account/copy_tables.php deleted file mode 100755 index 5186753..0000000 --- a/upgrade/account/copy_tables.php +++ /dev/null @@ -1,145 +0,0 @@ -#!/usr/bin/php5 -q - diff --git a/upgrade/account/copy_tables.sh b/upgrade/account/copy_tables.sh new file mode 100755 index 0000000..8f026c3 --- /dev/null +++ b/upgrade/account/copy_tables.sh @@ -0,0 +1,116 @@ +#!/usr/bin/env bash + +copyTable() { + echo "CREATE TABLE $2 LIKE $1;" + if [ -z "$3" ] ; then + echo "ALTER TABLE $2 ENGINE = InnoDB;" + fi + echo "INSERT INTO $2 SELECT * FROM $1;" +} + + +copyTable '#forums#.list' 'forums' +copyTable '#forums#.abos' 'forum_subs' +copyTable '#forums#.innd' 'forum_innd' +copyTable '#forums#.profils' 'forum_profiles' + +copyTable '#logger#.actions' 'log_actions' +copyTable '#logger#.events' 'log_events' +copyTable '#logger#.last_sessions' 'log_last_sessions' +copyTable '#logger#.sessions' 'log_sessions' + +copyTable '#paiement#.paiements' 'payments' +copyTable '#paiement#.codeC' 'payment_codeC' +copyTable '#paiement#.codeRCB' 'payment_codeRCB' +copyTable '#paiement#.methodes' 'payment_methods' +copyTable '#paiement#.transactions' 'payment_transactions' + +copyTable '#groupex#.announces' 'group_announces' +copyTable '#groupex#.announces_photo' 'group_announces_photo' +copyTable '#groupex#.announces_read' 'group_announces_read' +copyTable '#groupex#.asso' 'groups' +copyTable '#groupex#.dom' 'group_dom' +copyTable '#groupex#.evenements' 'group_events' +copyTable '#groupex#.evenements_items' 'group_event_items' +copyTable '#groupex#.evenements_participants' 'group_event_participants' +copyTable '#groupex#.membres' 'group_members' +copyTable '#groupex#.membres_sub_requests' 'group_member_sub_requests' +copyTable '#x4dat#.groupesx_auth' 'group_auth' + +copyTable '#x4dat#.axletter' 'axletter' +copyTable '#x4dat#.axletter_ins' 'axletter_ins' +copyTable '#x4dat#.axletter_rights' 'axletter_rights' + +copyTable '#x4dat#.newsletter' 'newsletter' +copyTable '#x4dat#.newsletter_art' 'newsletter_art' +copyTable '#x4dat#.newsletter_cat' 'newsletter_cat' +copyTable '#x4dat#.newsletter_ins' 'newsletter_ins' + +copyTable '#x4dat#.evenements' 'announces' +copyTable '#x4dat#.evenements_photo' 'announce_photos' +copyTable '#x4dat#.evenements_vus' 'announce_read' + +copyTable '#x4dat#.gapps_accounts' 'gapps_accounts' 'false' +copyTable '#x4dat#.gapps_nicknames' 'gapps_nicknames' 'false' +copyTable '#x4dat#.gapps_queue' 'gapps_queue' +copyTable '#x4dat#.gapps_reporting' 'gapps_reporting' + +copyTable '#x4dat#.contacts' 'contacts' +copyTable '#x4dat#.coupures' 'downtimes' +copyTable '#x4dat#.emails_watch' 'email_watch' +copyTable '#x4dat#.emails_send_save' 'email_send_save' +copyTable '#x4dat#.homonymes' 'homonyms' +copyTable '#x4dat#.ip_watch' 'ip_watch' +copyTable '#x4dat#.mx_watch' 'mx_watch' +copyTable '#x4dat#.ml_moderate' 'email_list_moderate' + +copyTable '#x4dat#.postfix_blacklist' 'postfix_blacklist' +copyTable '#x4dat#.postfix_mailseen' 'postfix_mailseen' +copyTable '#x4dat#.postfix_whitelist' 'postfix_whitelist' + +copyTable '#x4dat#.photo' 'profile_photos' +copyTable '#x4dat#.binets_def' 'profile_binet_enum' +copyTable '#x4dat#.binets_ins' 'profile_binets' +copyTable '#x4dat#.sections' 'profile_section_enum' +copyTable '#x4dat#.profile_medals' 'profile_medal_enum' +copyTable '#x4dat#.profile_medals_sub' 'profile_medals' +copyTable '#x4dat#.competences_def' 'profile_skill_enum' +copyTable '#x4dat#.competences_ins' 'profile_skills' +copyTable '#x4dat#.langues_def' 'profile_langskill_enum' +copyTable '#x4dat#.langues_ins' 'profile_langskills' + +copyTable '#x4dat#.register_marketing' 'register_marketing' +copyTable '#x4dat#.register_pending' 'register_pending' +copyTable '#x4dat#.register_subs' 'register_subs' +copyTable '#x4dat#.register_mstats' 'register_mstats' + +copyTable '#x4dat#.reminder' 'reminder' +copyTable '#x4dat#.reminder_type' 'reminder_type' + +copyTable '#x4dat#.requests' 'requests' +copyTable '#x4dat#.requests_answers' 'requests_answers' +copyTable '#x4dat#.requests_hidden' 'requests_hidden' + +copyTable '#x4dat#.search_autocomplete' 'search_autocomplete' +copyTable '#x4dat#.search_name' 'search_name' + +copyTable '#x4dat#.skins' 'skins' +copyTable '#x4dat#.tips' 'tips' + +copyTable '#x4dat#.survey_surveys' 'surveys' +copyTable '#x4dat#.survey_answers' 'survey_answers' +copyTable '#x4dat#.survey_votes' 'survey_votes' + +copyTable '#x4dat#.watch_profile' 'watch_profile' +copyTable '#x4dat#.perte_pass' 'account_lost_passwords' + +copyTable '#x4dat#.emails' 'emails' +copyTable '#x4dat#.aliases' 'aliases' +copyTable '#x4dat#.virtual' 'virtual' +copyTable '#x4dat#.virtual_domains' 'virtual_domains' +copyTable '#x4dat#.virtual_redirect' 'virtual_redirect' + +copyTable '#x4dat#.watch_nonins' 'watch_nonins' +copyTable '#x4dat#.watch_promo' 'watch_promo' + +copyTable '#x4dat#.openid_trusted' 'account_auth_openid' 'false' diff --git a/upgrade/account/update.sh b/upgrade/account/update.sh index a322ed9..49c65a2 100644 --- a/upgrade/account/update.sh +++ b/upgrade/account/update.sh @@ -10,24 +10,17 @@ echo "* press ^D to start import (^C to cancel)" cat echo -n "* create database " -(echo "CREATE DATABASE IF NOT EXISTS $DATABASE;" | $MYSQL) || die "ERROR" +(echo "CREATE DATABASE IF NOT EXISTS $DATABASE;" | mysql_run) || die "ERROR" echo "OK" echo -n "* copying tables " -./copy_tables.php || die "ERROR" +(./copy_tables.php | mysql_run) || die "ERROR" echo "OK" -for sql in ../newdirectory-0.0.1/*.sql +for sql in ../newdirectory-0.0.1/*.sql *.sql do echo -n "* running $sql " - (sed -e "s/#\([0-9a-z]*\)#/${DBPREFIX}\1/g" < $sql | $MYSQL $DATABASE >/dev/null) || die "ERROR" - echo "OK" -done - -for sql in *.sql -do - echo -n "* running $sql " - (sed -e "s/#\([0-9a-z]*\)#/${DBPREFIX}\1/g" < $sql | $MYSQL $DATABASE >/dev/null) || die "ERROR" + (cat $sql | mysql_run) || die "ERROR" echo "OK" done diff --git a/upgrade/inc/pervasive.sh b/upgrade/inc/pervasive.sh index 3eb0dae..b346707 100755 --- a/upgrade/inc/pervasive.sh +++ b/upgrade/inc/pervasive.sh @@ -22,6 +22,10 @@ function die() { exit 1 } +function mysql_run() { + sed -e "s/#\([0-9a-z]*\)#/${DBPREFIX}\1/g" | $MYSQL $DATABASE +} + function mailman_stop() { echo -n "stops mailman" /etc/init.d/mailman stop &>/dev/null