source: trunk/MagicSoft/Simulation/Corsika/Mmcs/c-script.sh@ 597

Last change on this file since 597 was 286, checked in by harald, 25 years ago
This is the start point for further developments of the Magic Monte Carlo Simulation written by Jose Carlos Gonzales. Now it is under control of one CVS repository for the whole collaboration. Everyone should use this CVS repository for further developments.
  • Property svn:executable set to *
File size: 3.9 KB
Line 
1#! /bin/sh
2
3readvalue () {
4 dfl="$1"
5 msg="$2"
6 desc="$3"
7
8 echo ''
9 echo $msg
10 echo -n "[ $dfl ] ? "
11 read value
12 value=${value:="$dfl"}
13 echo "$desc <- $value"
14}
15
16cat <<EOF
17
18MAGIC.MC.DAEMON Configuration Script
19========================================
20
21NOTE:: This script WILL NOT create any directory in
22 the case that it does not exist.
23 You MUST have created all the directories for yourself.
24 You will need :
25
26 - an [executables directory]: where I will look for
27 the CORSIKA executables and data files, and
28 for the MMD program.
29
30 - a [data directory]: where I will save the data.
31
32 - an [administration directory]: where some log-files
33 will be created.
34
35 If you DO NOT have yet these directories created, press
36 now Ctrl-C, create them, and write afterwards again
37
38 $ make script
39
40Press Return to continue, or Ctrl-C to stop this script.
41EOF
42read ans
43
44cat <<EOF
45+---------------------------------------------------+
46| This procedure will ask you about some parameters |
47| of your system. Please, answer all the questions. |
48| If you have any doubt, press Ctrl-C. |
49+---------------------------------------------------+
50EOF
51
52readvalue `pwd` \
53 "Directory where the CORSIKA and daemon executables should be located:" path-exe
54pathexe="$value"
55
56readvalue "c520-osf" \
57 "Enter the executable name:" name-exe
58nameexe="$value"
59
60readvalue "/data" \
61 "Disk/path where the bulk of data will be stored:" data-disk
62datadisk="$value"
63
64readvalue "/data" \
65 "Disk/path where the administration files will be stored:" adm-disk
66admdisk="$value"
67
68echo ''
69
70readvalue "0" \
71 "Final NICE value to use when running CORSIKA" niceval
72niceval="$value"
73
74readvalue "0" \
75 "What is your site seed generator?" siteval
76siteval="$value"
77
78readvalue "no" \
79 "Do you want to check the system load before running CORSIKA (yes/no)" MACH
80MACH="$value"
81
82echo ''
83
84readvalue "$USER@$HOST" \
85 "Enter the e-mail address to sent the log-mailing to" email-add
86useradd="$value"
87
88echo ''
89
90echo 'Preparing daemon . . .'
91
92cat <<EOF >dmy.sed
93s=#USERADD#=$useradd=g
94s=#DATADISK#=$datadisk=g
95s=#ADMDISK#=$admdisk=g
96s=#PATHEXE#=$pathexe=g
97s=#NAMEEXE#=$nameexe=g
98s=#NICE#=$niceval=g
99s=#SITE#=$siteval=g
100EOF
101
102sed -f dmy.sed magic-mc.daemon.tpl > mmd
103
104
105if [ $MACH = "yes" ]; then
106
107 cat <<EOF >> mmd
108# get information about system load
109if ( check_cpu_load() < 3 ) {
110 send_mail( "\n## Top output:\n\n" . \`\$TOP -b\`, 1 );
111 exit;
112}
113
114# make job
115make_job;
116
117# say bye, execute job and leave this program
118exec "\$SYSDIR/job.cmds"
119 or croak "Cannot execute job file";
120EOF
121
122else
123
124 cat <<EOF >> mmd
125# get information about system load
126check_cpu_load();
127
128# make job
129make_job;
130
131# say bye, execute job and leave this program
132exec "\$SYSDIR/job.cmds"
133 or croak "Cannot execute job file";
134EOF
135
136fi
137
138chmod 744 ${pathexe}/mmd
139
140echo 'MMD (MAGIC-MC.DAEMON) was generated.'
141
142echo ''
143
144echo 'The MAGIC-MC.DAEMON is designed to run from the crontab.'
145
146readvalue "yes" \
147 "Do you want me to change your crontab (yes/no)?" crntb
148crntb="$value"
149
150echo ''
151
152echo 'OK, I will change your crontab. I will asume you are using C-shell'
153
154if [ $crntb = "yes" ]; then
155 crontab -l > dmy
156 echo '0,15,30,45 * * * * '${pathexe}'/mmd -n'${niceval}' -q >& '${admdisk}'/last-crontab-out' >> dmy
157 crontab dmy
158 rm -f dmy
159fi
160
161echo ''
162echo 'Preparing your administration directory (do not worry about'
163echo 'some messages like "[file]: No such file or directory"'
164echo ''
165
166${pathexe}/mmd -c
167
168echo 'Done.'
169
170cat <<EOF
171
172MAGIC-MC.DAEMON is ready to run.
173
174If you did not ask me to modify your crontab,
175you must run yourself the program, with the following
176command line:
177
178$ mmd -n$niceval -q >& ${admdisk}/last-crontab-out
179
180However, it's much better if let my do the dirty work
181for you.
182
183Good luck.
184
185In case of problems, please contact to <gonzales@hegra1.mppmu.mpg.de>
186
187EOF
188
189
190
Note: See TracBrowser for help on using the repository browser.