Changeset 384


Ignore:
Timestamp:
Mar 22, 2010, 4:40:18 PM (11 years ago)
Author:
lucas
Message:

redmine-proj: cloudify

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ror-farm/redmine/redmine-proj

    r352 r384  
    2020# Settings
    2121defaultDB="admin_prod"
     22User="rormanager"
    2223analog_dir="/root/ror-farm/analog"
    2324vserver_dir="/var/lib/vservers"
    2425report_dir="/etc/ror-farm/analog"
     26
     27# Parse MySQL config
     28mysql_user=$(cat /home/$User/.my.cnf | grep "^user" | awk '{print $3}')
     29mysql_pass=$(cat /home/$User/.my.cnf | grep "^pass" | awk '{print $3}')
     30mysql_host="twix9"
    2531
    2632# Code
     
    7177fi
    7278
    73 unique=`echo "SELECT count(*) FROM projects WHERE identifier='$uniqueID' ;" | mysql $DataBase -N -B `
     79unique=`echo "SELECT count(*) FROM projects WHERE identifier='$uniqueID' ;" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host`
    7480if [ "$unique" != "0" ]
    7581then
     
    8793Fnow=`date +"%g%m%d%H%M"`
    8894
    89 idModule=`echo "SELECT id FROM enabled_modules ORDER BY id DESC LIMIT 1 ;" | mysql $DataBase -N -B `                                # get last module ID
    90 idProject=`echo "SELECT id FROM projects ORDER BY id DESC LIMIT 1 ;" | mysql $DataBase -N -B `                                      # get last projet ID
     95# get last module ID
     96idModule=`echo "SELECT id FROM enabled_modules ORDER BY id DESC LIMIT 1 ;" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host`
     97# get last projet ID
     98idProject=`echo "SELECT id FROM projects ORDER BY id DESC LIMIT 1 ;" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host`
    9199
    92100idProject=$(( $idProject + 1 )) # increment projet ID
     
    96104echo "Creating project for rorette $nom..."
    97105
    98 echo "INSERT INTO projects VALUES ($idProject,'$nom','$desc','$url',0,NULL,0,'$now','$now','$uniqueID',1);" | mysql $DataBase -N -B # Create a new projet with the previously parameters passed
    99 echo "INSERT INTO enabled_modules VALUES ($(( $idModule + 1)),$idProject,'issue_tracking');" | mysql $DataBase -N -B                # Enable module issue_tracking
    100 echo "INSERT INTO enabled_modules VALUES ($(( $idModule + 2)),$idProject,'time_tracking');" | mysql $DataBase -N -B                 # Enable module time_tracking
    101 echo "INSERT INTO enabled_modules VALUES ($(( $idModule + 3)),$idProject,'news');" | mysql $DataBase -N -B                          # Enable module news
    102 echo "INSERT INTO enabled_modules VALUES ($(( $idModule + 4)),$idProject,'documents');" | mysql $DataBase -N -B                     # Enable module documents
    103 echo "INSERT INTO enabled_modules VALUES ($(( $idModule + 5)),$idProject,'files');" | mysql $DataBase -N -B                         # Enable module files
    104 echo "INSERT INTO enabled_modules VALUES ($(( $idModule + 6)),$idProject,'wiki');" | mysql $DataBase -N -B                          # Enable module wiki
    105 echo "INSERT INTO enabled_modules VALUES ($(( $idModule + 7)),$idProject,'repository');" | mysql $DataBase -N -B                    # Enable module repository
    106 echo "INSERT INTO enabled_modules VALUES ($(( $idModule + 8)),$idProject,'boards');" | mysql $DataBase -N -B                        # Enable module boards
    107 echo "INSERT INTO enabled_modules VALUES ($(( $idModule + 9)),$idProject,'newissuealerts');" | mysql $DataBase -N -B                        # Enable module boards
    108 echo "INSERT INTO projects_trackers VALUES ($idProject,1),($idProject,2),($idProject,3);" | mysql $DataBase -N -B                   # Add the projects trackers
     106# Create a new projet with the previously parameters passed
     107echo "INSERT INTO projects VALUES ($idProject,'$nom','$desc','$url',0,NULL,0,'$now','$now','$uniqueID',1);" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host
     108# Enable module issue_tracking
     109echo "INSERT INTO enabled_modules VALUES ($(( $idModule + 1)),$idProject,'issue_tracking');" | mysql $DataBase -N -B  -u$mysql_user -p$mysql_pass -h$mysql_host
     110# Enable module time_tracking
     111echo "INSERT INTO enabled_modules VALUES ($(( $idModule + 2)),$idProject,'time_tracking');" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host
     112# Enable module news
     113echo "INSERT INTO enabled_modules VALUES ($(( $idModule + 3)),$idProject,'news');" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host
     114# Enable module documents
     115echo "INSERT INTO enabled_modules VALUES ($(( $idModule + 4)),$idProject,'documents');" | mysql $DataBase -N -B  -u$mysql_user -p$mysql_pass -h$mysql_host
     116# Enable module files
     117echo "INSERT INTO enabled_modules VALUES ($(( $idModule + 5)),$idProject,'files');" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host
     118# Enable module wiki
     119echo "INSERT INTO enabled_modules VALUES ($(( $idModule + 6)),$idProject,'wiki');" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host
     120# Enable module repository
     121echo "INSERT INTO enabled_modules VALUES ($(( $idModule + 7)),$idProject,'repository');" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host
     122# Enable module boards
     123echo "INSERT INTO enabled_modules VALUES ($(( $idModule + 8)),$idProject,'boards');" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host
     124# Enable module boards
     125echo "INSERT INTO enabled_modules VALUES ($(( $idModule + 9)),$idProject,'newissuealerts');" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host
     126# Add the projects trackers
     127echo "INSERT INTO projects_trackers VALUES ($idProject,1),($idProject,2),($idProject,3);" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host
    109128
    110129# Add documents
    111130
    112 idDocument=`echo "SELECT id FROM documents ORDER BY id DESC LIMIT 1 ;" | mysql $DataBase -N -B `                                    # get last document ID
    113 idAttachements=`echo "SELECT id FROM attachments ORDER BY id DESC LIMIT 1 ;" | mysql $DataBase -N -B `                              # get last attachments ID
     131# get last document ID
     132idDocument=`echo "SELECT id FROM documents ORDER BY id DESC LIMIT 1 ;" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host`
     133# get last attachments ID
     134idAttachements=`echo "SELECT id FROM attachments ORDER BY id DESC LIMIT 1 ;" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host`
    114135
    115136idDocument=$(( $idDocument + 1 ))         # document ID
    116137idAttachements=$(( $idAttachements + 1 )) # attachments ID
    117138
    118 echo "set names utf8;INSERT INTO documents VALUES ($idDocument,$idProject,1,'Statistiques','h1. Statistiques\r\n\r\nh2. Load\r\n\r\n!board-load.png!\r\n\r\n\r\n\r\nh2. Memory\r\n\r\n!board-memory.png!\r\n\r\n\r\n\r\nh2. Processus\r\n\r\n!board-proc.png!\r\n\r\n\r\n\r\nh2. Trafic\r\n\r\n!board-traffic.png!\r\n\r\n\r\n\r\nh2. Légende :\r\n\r\nChaque graphique reprend les statistiques pour la journée, la semaine, le mois et l\'année.\r\n\r\n+Load+ : mesure de la quantité de travail que doit effectuer le serveur. Si cette valeur est supérieure à 1, alors le CPU a plus de travail à réaliser que de temps de calcul disponible. Cette mesure recouvre aussi toutes les entrées/sorties telles que le travail des disques durs.\r\n\r\n+Memory+ : mémoire vive (RAM) consommée par vos applications.\r\n\r\n+Processus+ : nombre de processus en cours d\'exécution sur votre rorette.\r\n\r\n+Trafic+ : activité réseau (entrante + sortante) sur votre rorette.','$now')" | mysql $DataBase -N -B
     139echo "set names utf8;INSERT INTO documents VALUES ($idDocument,$idProject,1,'Statistiques','h1. Statistiques\r\n\r\nh2. Load\r\n\r\n!board-load.png!\r\n\r\n\r\n\r\nh2. Memory\r\n\r\n!board-memory.png!\r\n\r\n\r\n\r\nh2. Processus\r\n\r\n!board-proc.png!\r\n\r\n\r\n\r\nh2. Trafic\r\n\r\n!board-traffic.png!\r\n\r\n\r\n\r\nh2. Légende :\r\n\r\nChaque graphique reprend les statistiques pour la journée, la semaine, le mois et l\'année.\r\n\r\n+Load+ : mesure de la quantité de travail que doit effectuer le serveur. Si cette valeur est supérieure à 1, alors le CPU a plus de travail à réaliser que de temps de calcul disponible. Cette mesure recouvre aussi toutes les entrées/sorties telles que le travail des disques durs.\r\n\r\n+Memory+ : mémoire vive (RAM) consommée par vos applications.\r\n\r\n+Processus+ : nombre de processus en cours d\'exécution sur votre rorette.\r\n\r\n+Trafic+ : activité réseau (entrante + sortante) sur votre rorette.','$now')" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host
    119140
    120141# Add stats template
    121 echo "set names utf8;INSERT INTO documents VALUES ($(($idDocument + 1)),$idProject,1,'Fréquentation','Mise à jour dans la nuit a venir ...','$now')" | mysql $DataBase -N -B
     142echo "set names utf8;INSERT INTO documents VALUES ($(($idDocument + 1)),$idProject,1,'Fréquentation','Mise à jour dans la nuit a venir ...','$now')" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host
    122143
    123144# Load
    124 echo "INSERT INTO attachments VALUES ($(( $idAttachements + 1)),$idDocument,'Document','board-load.png','${Fnow}06_board-load.png',20000,'image/png','561ec13ba1b97e345c5534262ef5aff5',0,1,'$now','');" | mysql $DataBase -N -B
     145echo "INSERT INTO attachments VALUES ($(( $idAttachements + 1)),$idDocument,'Document','board-load.png','${Fnow}06_board-load.png',20000,'image/png','561ec13ba1b97e345c5534262ef5aff5',0,1,'$now','');" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host
    125146
    126147# Memory
    127 echo "INSERT INTO attachments VALUES ($(( $idAttachements + 2)),$idDocument,'Document','board-memory.png','${Fnow}16_board-memory.png',20000,'image/png','561ec13ba1b97e345c5534262ef5aff5',0,1,'$now','');" | mysql $DataBase -N -B
     148echo "INSERT INTO attachments VALUES ($(( $idAttachements + 2)),$idDocument,'Document','board-memory.png','${Fnow}16_board-memory.png',20000,'image/png','561ec13ba1b97e345c5534262ef5aff5',0,1,'$now','');" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host
    128149
    129150# Proc
    130 echo "INSERT INTO attachments VALUES ($(( $idAttachements + 3)),$idDocument,'Document','board-proc.png','${Fnow}26_board-proc.png',20000,'image/png','561ec13ba1b97e345c5534262ef5aff5',0,1,'$now','');" | mysql $DataBase -N -B
     151echo "INSERT INTO attachments VALUES ($(( $idAttachements + 3)),$idDocument,'Document','board-proc.png','${Fnow}26_board-proc.png',20000,'image/png','561ec13ba1b97e345c5534262ef5aff5',0,1,'$now','');" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host
    131152
    132153# Threads
    133 echo "INSERT INTO attachments VALUES ($(( $idAttachements + 4)),$idDocument,'Document','board-threads.png','${Fnow}36_board-threads.png',20000,'image/png','561ec13ba1b97e345c5534262ef5aff5',0,1,'$now','');" | mysql $DataBase -N -B
     154echo "INSERT INTO attachments VALUES ($(( $idAttachements + 4)),$idDocument,'Document','board-threads.png','${Fnow}36_board-threads.png',20000,'image/png','561ec13ba1b97e345c5534262ef5aff5',0,1,'$now','');" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host
    134155
    135156# Traffic
    136 echo "INSERT INTO attachments VALUES ($(( $idAttachements + 5)),$idDocument,'Document','board-traffic.png','${Fnow}46_board-traffic.png',20000,'image/png','561ec13ba1b97e345c5534262ef5aff5',0,1,'$now','');" | mysql $DataBase -N -B
     157echo "INSERT INTO attachments VALUES ($(( $idAttachements + 5)),$idDocument,'Document','board-traffic.png','${Fnow}46_board-traffic.png',20000,'image/png','561ec13ba1b97e345c5534262ef5aff5',0,1,'$now','');" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host
    137158
    138159# Create symbolic link
     
    153174ln -s /home/ror/monitoring/${nom}/board-traffic.png ${Fnow}46_board-traffic.png
    154175
    155 idWiki=`echo "SELECT id FROM wikis ORDER BY id DESC LIMIT 1 ;" | mysql $DataBase -N -B `                                            # get last wikis ID
    156 idPage=`echo "SELECT id FROM wiki_pages ORDER BY id DESC LIMIT 1 ;" | mysql $DataBase -N -B `                                       # get last page of wiki ID
    157 idCont=`echo "SELECT id FROM wiki_contents ORDER BY id DESC LIMIT 1 ;" | mysql $DataBase -N -B `                                    # get last content of page ID
     176# get last wikis ID
     177idWiki=`echo "SELECT id FROM wikis ORDER BY id DESC LIMIT 1 ;" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host`
     178# get last page of wiki ID
     179idPage=`echo "SELECT id FROM wiki_pages ORDER BY id DESC LIMIT 1 ;" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host`
     180# get last content of page ID
     181idCont=`echo "SELECT id FROM wiki_contents ORDER BY id DESC LIMIT 1 ;" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host`
    158182
    159183idWiki=$(( $idWiki + 1 )) # increment wiki ID
     
    161185idCont=$(( $idCont + 1 )) # increment content ID
    162186
    163 echo "INSERT INTO wikis VALUES ($idWiki,$idProject,'ReadmeRoR',1) ;" | mysql $DataBase -N -B                                        # Create the wiki
    164 echo "INSERT INTO wiki_pages VALUES ($idPage,$idWiki,'ReadmeRoR','$now',0,NULL);" | mysql $DataBase -N -B                           # Create the main wiki page called ReadmeRoR
     187# Create the wiki
     188echo "INSERT INTO wikis VALUES ($idWiki,$idProject,'ReadmeRoR',1) ;" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host
     189# Create the main wiki page called ReadmeRoR
     190echo "INSERT INTO wiki_pages VALUES ($idPage,$idWiki,'ReadmeRoR','$now',0,NULL);" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host
    165191
    166192#If you use Redmine 0.8, uncomment the previous line and comment the following line
    167 #echo "INSERT INTO wiki_pages VALUES ($idPage,$idWiki,'ReadmeRoR','$now');" | mysql $DataBase -N -B                           # Create the main wiki page called ReadmeRoR
    168 echo "INSERT INTO wiki_contents (id,page_id,author_id,text,comments,updated_on,version) SELECT $idCont,$idPage,1,text,'','$now',1 FROM wiki_contents WHERE id=7;" | mysql $DataBase -N -B
     193#echo "INSERT INTO wiki_pages VALUES ($idPage,$idWiki,'ReadmeRoR','$now');" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host
     194echo "INSERT INTO wiki_contents (id,page_id,author_id,text,comments,updated_on,version) SELECT $idCont,$idPage,1,text,'','$now',1 FROM wiki_contents WHERE id=7;" | mysql $DataBase -N -B -u$mysql_user -p$mysql_pass -h$mysql_host
    169195
    170196echo "...done"
Note: See TracChangeset for help on using the changeset viewer.