Changeset 385


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

redmine-add: cloudify

File:
1 edited

Legend:

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

    r352 r385  
    2020now=`date +"%F %X"`
    2121Database="admin_prod"
     22User="rormanager"
    2223project=0
    2324user=0
    2425right=0
    2526set=0
     27
     28# Parse MySQL config
     29mysql_user=$(cat /home/$User/.my.cnf | grep "^user" | awk '{print $3}')
     30mysql_pass=$(cat /home/$User/.my.cnf | grep "^pass" | awk '{print $3}')
     31mysql_host="twix9"
    2632
    2733function usage {
     
    7480  then
    7581    echo "Projects:"
    76     echo "SELECT id,name FROM projects" | mysql $Database -N -B 
     82    echo "SELECT id,name FROM projects" | mysql $Database -N -B  -u$mysql_user -p$mysql_pass -h$mysql_host
    7783  fi
    7884
     
    8086  then
    8187    echo "Users:"
    82     echo "SELECT id,login FROM users" | mysql $Database -N -B 
     88    echo "SELECT id,login FROM users" | mysql $Database -N -B  -u$mysql_user -p$mysql_pass -h$mysql_host
    8389  fi
    8490
     
    8692  then
    8793    echo "Roles:"
    88     echo "SELECT id,name FROM roles" | mysql $Database -N -B 
     94    echo "SELECT id,name FROM roles" | mysql $Database -N -B  -u$mysql_user -p$mysql_pass -h$mysql_host
    8995  fi
    9096
     
    9399  echo "Adding $user to project $project with role $right"
    94100
    95   c_user=`echo "SELECT COUNT(*) from users WHERE login = \"$user\"" | mysql $Database -N -B`
    96   c_proj=`echo "SELECT COUNT(*) from projects WHERE name = \"$project\"" | mysql $Database -N -B`
    97   c_righ=`echo "SELECT COUNT(*) from roles WHERE name = \"$right\"" | mysql $Database -N -B`
     101  c_user=`echo "SELECT COUNT(*) from users WHERE login = \"$user\"" | mysql $Database -N -B -u$mysql_user -p$mysql_pass -h$mysql_host`
     102  c_proj=`echo "SELECT COUNT(*) from projects WHERE name = \"$project\"" | mysql $Database -N -B -u$mysql_user -p$mysql_pass -h$mysql_host`
     103  c_righ=`echo "SELECT COUNT(*) from roles WHERE name = \"$right\"" | mysql $Database -N -B -u$mysql_user -p$mysql_pass -h$mysql_host`
    98104
    99105  if [ $c_user -ne 1 ] || [ $c_proj -ne 1 ] || [ $c_righ -ne 1 ]
     
    112118    fi
    113119  else
    114     id_user=`echo "SELECT id from users WHERE login = \"$user\" LIMIT 1 ;" | mysql $Database -N -B`
    115     id_proj=`echo "SELECT id from projects WHERE name = \"$project\" LIMIT 1 ;" | mysql $Database -N -B`
    116     id_righ=`echo "SELECT id from roles WHERE name = \"$right\" LIMIT 1 ;" | mysql $Database -N -B`
     120    id_user=`echo "SELECT id from users WHERE login = \"$user\" LIMIT 1 ;" | mysql $Database -N -B -u$mysql_user -p$mysql_pass -h$mysql_host`
     121    id_proj=`echo "SELECT id from projects WHERE name = \"$project\" LIMIT 1 ;" | mysql $Database -N -B -u$mysql_user -p$mysql_pass -h$mysql_host`
     122    id_righ=`echo "SELECT id from roles WHERE name = \"$right\" LIMIT 1 ;" | mysql $Database -N -B -u$mysql_user -p$mysql_pass -h$mysql_host`
    117123
    118     verif=`echo "select count(*) FROM members WHERE user_id = $id_user AND project_id = $id_proj ;" | mysql $Database -N -B`
     124    verif=`echo "select count(*) FROM members WHERE user_id = $id_user AND project_id = $id_proj ;" | mysql $Database -N -B -u$mysql_user -p$mysql_pass -h$mysql_host`
    119125    if [ $verif -ne 0 ] 
    120126    then
     
    123129    fi
    124130
    125     last_id=`echo "SELECT id from members ORDER BY id DESC LIMIT 1 ;" | mysql $Database -N -B`
     131    last_id=`echo "SELECT id from members ORDER BY id DESC LIMIT 1 ;" | mysql $Database -N -B -u$mysql_user -p$mysql_pass -h$mysql_host`
    126132
    127     echo "INSERT INTO members VALUES ($(( $last_id + 1 )),$id_user,$id_proj,$id_righ,\"$now\",0) ;" | mysql $Database -N -B
     133    echo "INSERT INTO members VALUES ($(( $last_id + 1 )),$id_user,$id_proj,$id_righ,\"$now\",0) ;" | mysql $Database -N -B -u$mysql_user -p$mysql_pass -h$mysql_host
    128134
    129135    echo "...done"
Note: See TracChangeset for help on using the changeset viewer.