public $components = array('RequestHandler');
public function index() {
+
+ // GETTING COMMAND CONTROLLER
+ App::import('Controller', 'Commands');
+ $commandsController = new CommandsController;
+
+ // GETTING ALL TASKS
$tasks = $this->Task->find('all');
+
+ // GETTING TASKS FOR EACH PATCH
+ $commandsArray = array();
+ foreach($tasks as $task) {
+
+ // GETTING TASKS ID
+ if($task['Task']['commands']) {
+ $commands_id = explode("|", $task['Task']['commands']);
+ $commands = array();
+ foreach($commands_id as $command_id) {
+ $commands[] = $commandsController->Command->findById($command_id);
+ }
+
+ // ADDIND TASKS TO ARRAY
+ $commandsArray[$task['Task']['id']] = $commands;
+ }
+ }
+
+ // SENDING DATA TO VIEW
+ $this->set(array(
+ 'commandsArray' => $commandsArray,
+ '_serialize' => array('commandsArray')
+ ));
$this->set(array(
'tasks' => $tasks,
'_serialize' => array('tasks')
}
}
}
+
+ public function order_command($id = null, $order = null, $direction = null) {
+ if (!$id) {
+ throw new NotFoundException(__('Tâche introuvable'));
+ }
+ $task = $this->Task->findById($id);
+ if (!$task) {
+ throw new NotFoundException(__('Tâche introuvable'));
+ }
+ $this->Task->id = $id;
+
+ // GETTING COMMANDS ID
+ $commands_id = explode("|", $task['Task']['commands']);
+
+ // CHANGING PLACES
+ $newCommands_id = array();
+ $key = $order-1;
+ if($direction == "up") {
+ $newkey = $key-1;
+ } else if($direction == "down") {
+ $newkey = $order;
+ }
+ foreach($commands_id as $command_id) {
+ $newCommands_id[] = $command_id;
+ }
+ if(isset($newkey)) {
+ $newCommands_id[$newkey] = $commands_id[$key];
+ $newCommands_id[$key] = $commands_id[$newkey];
+ }
+
+ // SAVING CHANGES
+ $this->Task->value('commands', implode("|", $newCommands_id));
+ $this->Task->save();
+ $this->redirect(array('action' => 'index'));
+ }
}
<table>
<tr>
<th>Nom</th>
- <th>Actions</th>
+ <th>Commandes</th>
</tr>
<?php if(isset($tasks)) { foreach ($tasks as $task): ?>
<tr>
<td><?php echo $task['Task']['name'] ?></td>
<td>
- <?php echo $this->Html->link(
+ <?php
+
+ // CHECKING COMMAND EXISTENCE
+ if(isset($commandsArray) && count($commandsArray) > 0) { ?>
+ <table>
+ <?php if(array_key_exists($task['Task']['id'], $commandsArray)) {
+ $order = 1;
+ foreach ($commandsArray[$task['Task']['id']] as $command): ?>
+ <tr>
+ <td><?php echo $command['Command']['value']; ?></td>
+ <td><?php echo $this->Html->link(
+ 'HAUT', array('controller' => 'tasks', 'action' => 'order_command', $task['Task']['id'], $order, "up")
+ ).' '.
+ $this->Html->link(
+ 'BAS', array('controller' => 'tasks', 'action' => 'order_command', $task['Task']['id'], $order, "down")
+ );
+ $order++;?>
+ </td>
+ </tr>
+ <?php endforeach; } ?>
+ </table>
+ <?php }
+ echo $this->Html->link(
'Nouvelle commande',
array('controller' => 'commands', 'action' => 'add', $task['Task']['id'])
); ?>
#save metadata
for b in $DBS
do
- mysqldump --add-locks --add-drop-table -u"alfresco" -palfresco $b 1> $DIR/$b.sql
+ mysqldump --add-locks --add-drop-table -ualfresco -palfresco $b 1> $DIR/$b.sql
done
#save backup cmd
cd $HER
#!/bin/bash
-cd /opt/iParapheur
-
# ADDING NEW KEYS TO OLD CONFIG
-awk -F= '!a[$1]++' tomcat/shared/classes/alfresco-global.properties add-alfresco > merged-alfresco-global.properties
+awk -F= '!a[$1]++' tomcat/shared/classes/alfresco-global.properties /opt/_install/iParapheur-v4.2.07/confs/add-alfresco > merged-alfresco-global.properties
# REWRITING SOME VALUES
declare -A rewritevalues
key=$(echo "$line" | cut -d '=' -f 1)
rewritevalues[$key]=$(echo "$line" | cut -d '=' -f 2-)
fi
-done < rewrite-alfresco
+done < /opt/_install/iParapheur-v4.2.07/confs/rewrite-alfresco
cp merged-alfresco-global.properties /tmp/tmpfile
do
obsoletevalues[$i]=$(echo "$line")
((i++))
-done < obsolete-alfresco
+done < /opt/_install/iParapheur-v4.2.07/confs/obsolete-alfresco
cp merged-alfresco-global.properties /tmp/tmpfile
#!/bin/bash
-cd /opt/iParapheur
-
# ADDING NEW KEYS TO OLD CONFIG
-awk -F= '!a[$1]++' tomcat/shared/classes/iparapheur-global.properties add-iparapheur > merged-iparapheur-global.properties
+awk -F= '!a[$1]++' tomcat/shared/classes/iparapheur-global.properties /opt/_install/iParapheur-v4.2.07/confs/add-iparapheur > merged-iparapheur-global.properties
# REWRITING SOME VALUES
declare -A rewritevalues
key=$(echo "$line" | cut -d '=' -f 1)
rewritevalues[$key]=$(echo "$line" | cut -d '=' -f 2-)
fi
-done < rewrite-iparapheur
+done < /opt/_install/iParapheur-v4.2.07/confs/rewrite-iparapheur
cp merged-iparapheur-global.properties /tmp/tmpfile
do
obsoletevalues[$i]=$(echo "$line")
((i++))
-done < obsolete-iparapheur
+done < /opt/_install/iParapheur-v4.2.07/confs/obsolete-iparapheur
cp merged-iparapheur-global.properties /tmp/tmpfile
# Arrêt de tomcat + frontal web
echo -n "Arrêt des services..."
-service alfresco stop
+service alfresco stop > /dev/null
service nginx stop
printf "${GREEN}OK${NC}\n"
+# [Prereq] Fichier AMP intègre
+echo -n "Tests d'intégrité du nouvel AMP..."
+cd /opt/_install/iParapheur-v4.2.07/
+mv iParapheur-v4.2.07*.amp iParapheur-v4.2.07.amp
+if [ ! -s iParapheur-v4.2.07.amp ]
+then
+ printf "${RED}Vide${NC}\n"
+ exit 1
+fi
+if [ ! -s iParapheur-v4.2.07.amp.md5sum ]
+then
+ printf "${RED}Hash introuvable${NC}\n"
+ exit 1
+fi
+if [ `md5sum iParapheur-v4.2.07.amp | awk '{print $1}'` != `cat iParapheur-v4.2.07.amp.md5sum` ]
+then
+ printf "${RED}Corrompu${NC}\n"
+ exit 1
+fi
+printf "${GREEN}OK${NC}\n"
+
# Remplacement AMP
-echo -n "Remplacement de l'AMP..."
+echo -n "Remplacement de l'ancien AMP..."
rm -f /opt/iParapheur/amps/*
-cp /opt/_install/iParapheur-v4.2.07/iParapheur-v4.2.07*.amp /opt/iParapheur/amps/
+cp /opt/_install/iParapheur-v4.2.07/iParapheur-v4.2.07.amp /opt/iParapheur/amps/
+printf "${GREEN}OK${NC}\n"
+
+# [Prereq] Configuration backup OK
+echo -n "Ajustement de la configuration de la sauvegarde..."
+cd /opt/_install/iParapheur-v4.2.07/confs
+./update_backup_access.sh
+cp backup_parapheur.sh /opt/iParapheur && mkdir -p /opt/iParapheur/backups
+if [ "$(./test_fulldisk_backups.sh)" -eq 0 ]
+then
+ printf "${RED}Pas assez d'espace${NC}\n"
+ exit 1
+fi
printf "${GREEN}OK${NC}\n"
-# Script de backup
+# Sauvegarde
echo -n "Sauvegarde..."
cd /opt/iParapheur && ./backup_parapheur.sh
printf "${GREEN}OK${NC}\n"
# [Prereq] Fichier alfresco.war original intègre
-#echo -n "Tests d'intégrité des webapps originales..."
-#cd /opt/iParapheur/tomcat/webapps
-#if [ -s alfresco.war ]
-#then
-# if [ -s alfresco.war.md5sum ]
-# then
-# if [ `md5sum alfresco.war | awk '{print $1}'` == `cat alfresco.war.md5sum` ]
-# then
-# printf "${GREEN}OK${NC}\n"
-# else
-# printf "${RED}Corrompu${NC}\n"
-# exit 1
-# fi
-# else
-# printf "${RED}Hash introuvable${NC}\n"
-# exit 1
-# fi
-#else
-# printf "${RED}Vide${NC}\n"
-# exit 1
-#fi
+echo -n "Tests d'intégrité des webapps originales..."
+cd /opt/iParapheur/tomcat/webapps
+if [ ! -s alfresco.war ]
+then
+ printf "${RED}Vide${NC}\n"
+ exit 1
+fi
+if [ ! -s alfresco.war.md5sum ]
+then
+ printf "${RED}Hash introuvable${NC}\n"
+ exit 1
+fi
+if [ `md5sum alfresco.war | awk '{print $1}'` != `cat alfresco.war.md5sum` ]
+then
+ printf "${RED}Corrompu${NC}\n"
+ exit 1
+fi
+cp alfresco.war ../../alfresco.war.safe
+printf "${GREEN}OK${NC}\n"
# Déploiement des nouvelles sources
cd /opt/iParapheur && ./iparaph-updateAMP.sh
# Modif conf alfresco
echo -n "Mise à jour de la configuration alfresco..."
cd /opt/iParapheur ; cp /opt/_install/iParapheur-v4.2.07/confs/fusion_conf_alfresco.sh .
-cp /opt/_install/iParapheur-v4.2.07/confs/add-alfresco .
-cp /opt/_install/iParapheur-v4.2.07/confs/rewrite-alfresco .
-cp /opt/_install/iParapheur-v4.2.07/confs/obsolete-alfresco .
./fusion_conf_alfresco.sh
+rm fusion_conf_alfresco.sh
printf "${GREEN}OK${NC}\n"
# Connecteur WS
# Modif conf iparapheur
echo -n "Mise à jour de la configuration iparapheur..."
cd /opt/iParapheur ; cp /opt/_install/iParapheur-v4.2.07/confs/fusion_conf_iparapheur.sh .
-cp /opt/_install/iParapheur-v4.2.07/confs/add-iparapheur .
-cp /opt/_install/iParapheur-v4.2.07/confs/rewrite-iparapheur .
-cp /opt/_install/iParapheur-v4.2.07/confs/obsolete-iparapheur .
./fusion_conf_iparapheur.sh
+rm fusion_conf_iparapheur.sh
printf "${GREEN}OK${NC}\n"
# Redéploiement webapp iparapheur
# Démarrage alfresco + frontal web
echo -n "Redémarrage des services..."
service nginx start
-service alfresco start
+service alfresco start > /dev/null
printf "${GREEN}OK${NC}\n"
--- /dev/null
+#!/bin/bash
+cd /opt/iParapheur
+echo "$(df -Ph backups | tail -1 | awk '{print $4}' | sed -e 's/\(.*\)G/\1/g' | sed -e 's/,/./g')"">0.1" | bc
--- /dev/null
+#!/bin/bash
+username=$(cat /opt/iParapheur/tomcat/shared/classes/alfresco-global.properties | grep db.username | awk -F= '{print $2}')
+password=$(cat /opt/iParapheur/tomcat/shared/classes/alfresco-global.properties | grep db.password | awk -F= '{print $2}')
+sed -e 's!mysqldump\(.*\)!mysqldump --add-locks --add-drop-table -u'"${username}"' -p'"${password}"' $b 1> $DIR/$b.sql!g' backup_parapheur.sh > /tmp/tmpfile
+mv /tmp/tmpfile backup_parapheur.sh