Use configured resolution for login/outgame/ingame
[ryzomcore.git] / ryzom / tools / scripts / linux / utilities
blob59c50a7a7e642139b5ae7ef4116bc42aa1ff2d4b
1 #!/bin/sh -
3 SSH_AGENT_FILE="$HOME/ssh_agent_file"
5 BASENAME=`basename $0`
6 LOG_INFO="$RYZOM_PATH/log/${BASENAME}_info.log"
7 LOG_ERROR="$RYZOM_PATH/log/${BASENAME}_error.log"
9 # first param is the subject line
10 # others params are email
11 send_mail()
13 SUBJECT=$1
14 shift
15 echo Send mail to $* with log $LOG_ERROR in body and subject $SUBJECT
16 cat $LOG_ERROR | mail -s "$SUBJECT on `hostname`" $*
19 print_success()
21 echo "*********************** $* SUCCESS !"
22 echo
25 print_failure()
27 echo "***************************************************"
28 echo "***************************************************"
29 echo "*********************** $* FAILED"
30 echo "***************************************************"
31 echo "***************************************************"
35 # failed fill the log and send email if necessary
36 # argument are the error message
37 failed()
39 print_failure $*
40 if [ "X$LOG_INFO" != "X" ]
41 then
42 print_failure $* >> $LOG_INFO
44 if [ "X$LOG_ERROR" != "X" ]
45 then
46 print_failure $* >> $LOG_ERROR
49 if [ "X$MAIL_ERROR" != "X" ]
50 then
51 send_mail "$* FAILED" $MAIL_ERROR
52 else
53 echo "No email to send the error mail" >> $LOG_ERROR
56 echo "exiting..."
57 exit
60 # useful function to avoid continuing if something goes wrong
61 # first param is $? and second is the string that will display
62 verify()
64 if [ $1 -eq 0 ]
65 then
66 shift
67 print_success $*
68 if [ "X$LOG_INFO" != "X" ]
69 then
70 print_success $* >> $LOG_INFO
72 if [ "X$LOG_ERROR" != "X" ]
73 then
74 print_success $* >> $LOG_ERROR
76 else
77 shift
78 failed $*
82 # step_failed() fills the log and increments $STEPS_FAILURES
83 step_failed()
85 print_failure $*
86 if [ "X$LOG_INFO" != "X" ]
87 then
88 print_failure $* >> $LOG_INFO
90 if [ "X$LOG_ERROR" != "X" ]
91 then
92 print_failure $* >> $LOG_ERROR
95 if [ "X$STEPS_FAILURES" = "X" ]
96 then
97 STEPS_FAILURES=0
98 else
99 STEPS_FAILURES=`expr $STEPS_FAILURES + 1`
103 # call init_steps() before you use step()
104 # it takes a label for following steps as parameter
105 init_steps()
107 STEPS_LABEL="$*"
108 STEPS_FAILURES=0
111 # like verify() but will continue even if step failed until verify_steps() is called
112 # first param is $? and second is the string that will display
113 step()
115 if [ $1 -eq 0 ]
116 then
117 shift
118 print_success $*
119 if [ "X$LOG_INFO" != "X" ]
120 then
121 print_success $* >> $LOG_INFO
123 if [ "X$LOG_ERROR" != "X" ]
124 then
125 print_success $* >> $LOG_ERROR
127 else
128 shift
129 step_failed $*
133 # call verify_steps() when you want to stop if error(s) occurred in previous steps
134 verify_steps()
136 if [ $STEPS_FAILURES -eq 0 ]
137 then
138 print_success $STEPS_LABEL
139 if [ "X$LOG_INFO" != "X" ]
140 then
141 print_success $STEPS_LABEL >> $LOG_INFO
143 if [ "X$LOG_ERROR" != "X" ]
144 then
145 print_success $STEPS_LABEL >> $LOG_ERROR
147 else
148 if [ $STEPS_FAILURES -eq 1 ]
149 then
150 failed "1 step failed: $STEPS_LABEL"
151 else
152 failed "$STEPS_FAILURES steps failed: $STEPS_LABEL"
157 ask_confirmation()
159 echo "Using this script will destroy the current version, type 'yes' if you really want to do that"
160 read CONF
161 if [ "X$CONF" != "Xyes" ]; then
162 failed "You didn't answer 'yes', I stop the script!"
166 check_host()
168 HOST=`hostname -s`
169 if [ "X$HOST" != "X$1" ]; then
170 failed "You can execute this script only on '$1' and not on '$HOST'"
174 # useful function to initialize the default log for all scripts
175 init()
177 if [ "X$LOG_INFO" != "X" ]
178 then
179 test -d `dirname $LOG_INFO` || mkdir -p `dirname $LOG_INFO`
180 test ! -f $LOG_INFO || rm $LOG_INFO
181 touch $LOG_INFO
182 # display all ulimit in the log
183 ulimit -a >>$LOG_INFO
186 if [ "X$LOG_ERROR" != "X" ]
187 then
188 test -d `dirname $LOG_ERROR` || mkdir -p `dirname $LOG_ERROR`
189 test ! -f $LOG_ERROR || rm $LOG_ERROR
190 touch $LOG_ERROR
194 init_ssh()
196 if [ ! -f $SSH_AGENT_FILE ]
197 then
198 failed "the file $SSH_AGENT_FILE not exist, you must call create_ssh_agent_file first"
201 eval `cat $SSH_AGENT_FILE`