Commit 9a562cda authored by Cédric BRINER's avatar Cédric BRINER Committed by Cédric BRINER
Browse files

remove prd-prd

parent a10f862b
......@@ -1611,133 +1611,6 @@ EOF
echo -e "\e[34m############################################################\e[0m"
}
function prd_prd
{
echo -e "\e[34m############################################################\e[0m"
echo -e "\e[34mSTART OF IDP-TOOL PRD-PRD\e[0m"
echo -e "\e[34mdate:$(date "+%Y.%m.%d_%Hh%Mm_%A")\e[0m"
echo ""
is_purge_only=$1
#
mysql_outfile=/var/tmp/mysql-outfile.${date}
prd2prd_from="idp3"
prd2prd_to="luniidpprd5"
time_to_stabilize=3
time_max_to_sync=500
bs_limit=
this_host=$(hostname -s)
waited_time=0
if test "${this_host}" != "${prd2prd_to}"
then
echo -e "\e[31mprd-prd command could only be invoked on host(${prd2prd_to})!\e[0m"
echo -e "\e[34mExit.\e[0m"
exit 1
fi
#
# CONSENTMENT
echo -e "\e[34mYou are in the process to change the production server.\e[0m"
echo -e " \e[34mDoing so will erase all the data on host(${this_host}),\e[0m"
echo -e " \e[34mas they will be copied from idp3.\e[0m"
echo -en " \e[34mIf you want to process type (go ahead):\e[0m"
read -r reply
if test "${reply}" != "go ahead"
then
echo -e " \e[34mOkay, you did not give us the good meesage, exit !\e[0m"
exit 0
fi
echo -e " \e[34mlet us go !\e[0m"
#
# PURGE SHIBPID
echo -e " \e[34m- purge shibpid\e[0m"
echo -e " \e[34m- remove all the previous record on host(${prd2prd_to}).\e[0m" | indent 1
if test "0" != "$(mysql -u root -p$(get_mysql_pw) shibboleth -e "select count(*) from shibpid;" | tail -1)"
then
echo -e "\e[34m- delete from shibpid with command (~1min):\e[0m" | indent 3
echo -e "\e[34mmysql -u root -p shibboleth -e 'delete from shibpid;':\e[0m" | indent 5
{ time mysql -u root -p$(get_mysql_pw) shibboleth -e "delete from shibpid;" ; } |& indent 7
echo -e "\e[34mdeleted\e[0m" | indent 5
echo -e "\e[34m- wait tungsten stabilize (~4min)\e[0m"| indent 3
tungsten_stable ${waited_time} 5
waited_time=$?
else
echo -e "\e[34m - nothing todo as the table is empty\e[0m" | indent 5
fi
if test "${is_purge_only}" = "True"
then
echo ""
echo -e "\e[34mAs the flag '--purge-only' is present, we won't neither dump idp3 neither load shibpid neither write the fallback.\e[0m"
echo ""
echo -e "\e[34mdate:$(date "+%Y.%m.%d_%Hh%Mm_%A")\e[0m"
echo -e "\e[34mEND OF IDP-TOOLS PRD-PRD\e[0m"
echo -e "\e[34m############################################################\e[0m"
echo -e "\e[34mExit\e[0m"
exit
fi
#
# DUMP IDP3
echo -e " \e[34m- dump idp3\e[0m"
ssh idp3 "/usr/local/bin/idp-tools select-into-outfile ${mysql_outfile}" |& indent 5
sscp "${mysql_outfile}" idp3:${mysql_outfile} ${mysql_outfile}
ssh idp3 "test -f ${mysql_outfile} && rm ${mysql_outfile}"
echo -e " \e[34m- remove the bad uuid based persistendID\e[0m"
grep -v "\s[[:xdigit:]]\{8\}\(-[[:xdigit:]]\{4\}\)\{3\}-[[:xdigit:]]\{12\}\s" ${mysql_outfile} > ${mysql_outfile}_no_uuid.load
#
# LOAD SHIBPID
echo -e "\e[34m- load shibpid\e[0m" | indent 1
echo -e "\e[34m- load data from file, with command (~1min):\e[0m" | indent 3
echo -e "\e[34mmysql -u root -p shibboleth -e 'LOAD DATA INFILE ${mysql_outfile}_no_uuid.load IGNORE INTO TABLE shibboleth.shibpid;')\e[0m" | indent 5
{ time mysql -u root -p"$(get_mysql_pw)" shibboleth -e "LOAD DATA INFILE '${mysql_outfile}_no_uuid.load' IGNORE INTO TABLE shibboleth.shibpid;" ; } |& indent 7
echo -e "\e[34mloaded\e[0m" | indent 7
echo -e " \e[34m- wait tungsten stabilize (~4min)\e[0m"| indent 3
tungsten_stable ${waited_time} 5
waited_time=$?
#
# count verification
nb_shib_new=$(mysql -u root -p$(get_mysql_pw) shibboleth -e "select count(*) from shibpid;" | tail -1)
nb_shib_old=$(wc -l ${mysql_outfile}_no_uuid.load | cut -d " " -f1)
echo -en "\lee[34m- count verification : \e[0m" | indent 1
if test ${nb_shib_old} -eq ${nb_shib_new}
then
echo -e "\e[32mok\e[34m from:${nb_shib_old} to:${nb_shib_new} \e[0m"
else
echo -e "\e[31mko\e[34m from:${nb_shib_old} to:${nb_shib_new} \e[0m"
fi
#
# FALLBACK
echo -e "\e[34m- fallback command to generate the new entry shibpid\e[0m" | indent 1
echo -e "\e[34m- the comand is :\e[0m" | indent 3
echo -e "\e[34mvvvvvvvvvv start command vvvvvvvvvv\e[0m"
date_mysql_str=$(date '+%Y-%m-%d %H:%M:%S')
date_mysql_file_str=$(echo ${date_mysql_str} | tr -s " " "_" | tr -s ":" ".")
fallback_script_path="/root/idp-fallback-command-for-migration-at-${date_mysql_file_str}_with_a_waited_time_of_${waited_time}.bash"
{
echo '#!/bin/bash'
echo "date_fallback_str="'$(date "+%Y.%m.%d_%Hh%Mm%Ss")'
echo 'echo "date : ${date_fallback_str}"'
echo "path_fallback=/var/tmp/idp_fallback_at_"'${date_fallback_str}'"_of_migration_at_${date_mysql_file_str}.mysql"
echo 'echo "path : ${path_fallback}"'
echo "mysql -u root \\"
echo " -p"'$(grep mysql.password /opt/shibboleth-idp/conf/unige.environment.properties | sed "s|.*=\s*||")'" \\"
echo " -e 'SELECT * FROM shibboleth.shibpid where date(creationdate) > \"${date_mysql_str}\" INTO OUTFILE \"'"'${path_fallback}'"'\";'"
echo "#"
echo "echo '# do on idp3 something as:'"
echo "echo \"# mysql -u root -p\\\$PASS shibboleth -e 'select count(*) from shibpid;'\""
echo "echo \"# mysql -u root -p\\\$PASS shibboleth -e 'LOAD DATA INFILE \\\"/var/tmp/"'$(basename $path_fallback)'"\\\" ;'\""
echo "echo \"# mysql -u root -p\\\$PASS shibboleth -e 'select count(*) from shibpid;'\""
} | tee ${fallback_script_path}
chmod +x ${fallback_script_path}
echo -e "\e[34m^^^^^^^^^^ end command ^^^^^^^^^^^^\e[0m"
echo -e "\e[34m- a copy of the command will be on :\e[0m" | indent 3
echo -e "\e[34m${fallback_script_path}\e[0m" | indent 5
echo -e ""
echo -e "\e[34mdate:$(date "+%Y.%m.%d_%Hh%Mm_%A")\e[0m"
echo -e "\e[34mEND OF IDP-TOOLS PRD-PRD\e[0m"
echo -e "\e[34m############################################################\e[0m"
}
TUNGSTEN_TIME_MAX_STABILIZE=3
TUNGSTEN_TIME_MAX_SYNC=1000
......@@ -2039,7 +1912,6 @@ function usage_n_exit
pb " | dump-mysql"
pb " | load-mysql <dump_path>]"
pb " | sync [--no-restart] <to_host>"
pb " | prd-prd [--purge-only]"
pb " | watch-sync <other_host>"
pb " | reload"
pb " | aacli [-h | -l [<entityId>] | [-r] <user> <entityId>]"
......@@ -2111,21 +1983,6 @@ case "$1" in
echo "RESTART_DAEMON(${RESTART_DAEMON}) Host(${host})"
sync "${host}" | tee /${IDP_HOME}/sync_logs/$(date "+%Y.%m.%d_%Hh%Mm_%A").txt.out
;;
prd-prd)
has_ssh_agent
shift
is_purge_only="False"
if test ! -z "$1"
then
if test "$1" = "--purge-only"
then
is_purge_only="True"
else
usage_n_exit
fi
fi
prd_prd ${is_purge_only}
;;
watch-sync)
has_ssh_agent
watch_sync $2
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment