]> git.ipfire.org Git - ipfire-2.x.git/blob - tools/make-functions
Installer-Toolchain nochmals ueberarbeitet.
[ipfire-2.x.git] / tools / make-functions
1 #!/bin/bash
2 ############################################################################
3 #
4 # Beautifying variables & presentation & input output interface
5 #
6 ############################################################################
7
8 ## Screen Dimentions
9 # Find current screen size
10 if [ -z "${COLUMNS}" ]; then
11 COLUMNS=$(stty size)
12 COLUMNS=${COLUMNS##* }
13 fi
14
15 # When using remote connections, such as a serial port, stty size returns 0
16 if [ "${COLUMNS}" = "0" ]; then
17 COLUMNS=80
18 fi
19
20 ## Measurements for positioning result messages
21 RESULT_WIDTH=4
22 TIME_WIDTH=8
23 OPT_WIDTH=6
24 VER_WIDTH=10
25 RESULT_COL=$((${COLUMNS} - $RESULT_WIDTH - 4))
26 TIME_COL=$((${RESULT_COL} - $TIME_WIDTH - 5))
27 OPT_COL=$((${TIME_COL} - $OPT_WIDTH - 5))
28 VER_COL=$((${OPT_COL} - $VER_WIDTH - 5))
29
30 ## Set Cursur Position Commands, used via echo -e
31 SET_RESULT_COL="\\033[${RESULT_COL}G"
32 SET_TIME_COL="\\033[${TIME_COL}G"
33 SET_OPT_COL="\\033[${OPT_COL}G"
34 SET_VER_COL="\\033[${VER_COL}G"
35
36 # Define color for messages
37 BOLD="\\033[1;39m"
38 DONE="\\033[1;32m"
39 SKIP="\\033[1;34m"
40 WARN="\\033[1;35m"
41 FAIL="\\033[1;31m"
42 NORMAL="\\033[0;39m"
43
44 evaluate() {
45 if [ "$?" -eq "0" ]; then
46 beautify message DONE
47 else
48 EXITCODE=$1
49 shift 1
50 beautify message FAIL
51 $*
52 if [ $EXITCODE -ne "0" ]; then
53 exit $EXITCODE
54 fi
55 fi
56 }
57
58 position_cursor()
59 {
60 # ARG1=starting position on screen
61 # ARG2=string to be printed
62 # ARG3=offset, negative for left movement, positive for right movement, relative to ARG1
63 # For example if your starting position is column 50 and you want to print Hello three columns to the right
64 # of your starting position, your call will look like this:
65 # position_cursor 50 "Hello" 3 (you'll get the string Hello at position 53 (= 50 + 3)
66 # If on the other hand you want your string "Hello" to end three columns to the left of position 50,
67 # your call will look like this:
68 # position_cursor 50 "Hello" -3 (you'll get the string Hello at position 42 (= 50 - 5 -3)
69 # If you want to start printing at the exact starting location, use offset 0
70
71 START=$1
72 STRING=$2
73 OFFSET=$3
74
75 STRING_LENGTH=${#STRING}
76
77 if [ ${OFFSET} -lt 0 ]; then
78 COL=$((${START} + ${OFFSET} - ${STRING_LENGTH}))
79 else
80 COL=$((${START} + ${OFFSET}))
81 fi
82
83 SET_COL="\\033[${COL}G"
84
85 echo $SET_COL
86 } # End of position_cursor()
87
88
89 beautify()
90 {
91 # Commands: build_stage, make_pkg, message, result
92 case "$1" in
93 message)
94 case "$2" in
95 DONE)
96 echo -ne "${SET_RESULT_COL}[${DONE} DONE ${NORMAL}]\n"
97 ;;
98 WARN)
99 echo -ne "${WARN}${3}${NORMAL}${SET_RESULT_COL}[${WARN} WARN ${NORMAL}]\n"
100 ;;
101 FAIL)
102 echo -ne "${SET_RESULT_COL}[${FAIL} FAIL ${NORMAL}]\n"
103 ;;
104 SKIP)
105 echo -ne "${SET_RESULT_COL}[${SKIP} SKIP ${NORMAL}]\n"
106 ;;
107 esac
108 ;;
109 build_stage_start)
110 MESSAGE=$2
111 STAGE_TIME_START=`date +%s`
112 echo -ne "${BOLD}*** ${MESSAGE}${SET_VER_COL} version${SET_OPT_COL} options"
113 echo -ne "${SET_TIME_COL} time (sec)${SET_RESULT_COL} status${NORMAL}\n"
114 ;;
115 build_stage_end)
116 STAGE_TIME_END=`date +%s`
117 echo -ne "${BOLD}***This stage took:\t\t $[ $STAGE_TIME_END - $STAGE_TIME_START ] (secs)${NORMAL}\n"
118 ;;
119 build_start)
120 BUILD_TIME_START=`date +%s`
121 ;;
122 build_end)
123 BUILD_TIME_END=`date +%s`
124 echo -ne "${BOLD}***Build is finished now!\nThis took:\t\t\t $[ $BUILD_TIME_END - $BUILD_TIME_START ] (secs)${NORMAL}\n"
125 ;;
126 make_pkg)
127 echo "$2" | while read PKG_VER PROGRAM OPTIONS
128 do
129 SET_VER_COL_REAL=`position_cursor $OPT_COL $PKG_VER -3`
130
131 if [ "$OPTIONS" == "" ]; then
132 echo -ne "${PROGRAM}${SET_VER_COL}[ ${BOLD}${SET_VER_COL_REAL}${PKG_VER}"
133 echo -ne "${NORMAL} ]${SET_RESULT_COL}"
134 else
135 echo -ne "${PROGRAM}${SET_VER_COL}[ ${BOLD}${SET_VER_COL_REAL}${PKG_VER}"
136 echo -ne "${NORMAL} ]${SET_OPT_COL}[ ${BOLD}${OPTIONS}"
137 echo -ne "${NORMAL} ]${SET_RESULT_COL}"
138 fi
139 done
140 ;;
141 result)
142 RESULT=$2
143
144 if [ ! $3 ]; then
145 PKG_TIME=0
146 else
147 PKG_TIME=$3
148 fi
149
150 SET_TIME_COL_REAL=`position_cursor $RESULT_COL $PKG_TIME -3`
151 case "$RESULT" in
152 DONE)
153 echo -ne "${SET_TIME_COL}[ ${BOLD}${SET_TIME_COL_REAL}$PKG_TIME${NORMAL} ]"
154 echo -ne "${SET_RESULT_COL}[${DONE} DONE ${NORMAL}]\n"
155 ;;
156 FAIL)
157 echo -ne "${SET_TIME_COL}[ ${BOLD}${SET_TIME_COL_REAL}$PKG_TIME${NORMAL} ]"
158 echo -ne "${SET_RESULT_COL}[${FAIL} FAIL ${NORMAL}]\n"
159 ;;
160 SKIP)
161 echo -ne "${SET_TIME_COL}[ ${BOLD}${SET_TIME_COL_REAL}$PKG_TIME${NORMAL} ]"
162 echo -ne "${SET_RESULT_COL}[${SKIP} SKIP ${NORMAL}]\n"
163 ;;
164 esac
165 ;;
166 esac
167 } # End of beautify()
168
169
170 get_pkg_ver()
171 {
172 PKG_VER=`grep ^VER $1 | awk '{print $3}'`
173
174 if [ -z $PKG_VER ]; then
175 PKG_VER=`grep "Exp " $1 | awk '{print $4}'`
176 fi
177
178 if [ ${#PKG_VER} -gt $VER_WIDTH ]; then
179 # If a package version number is greater than $VER_WIDTH, we keep the first 4 characters
180 # and replace enough characters to fit the resulting string on the screen. We'll replace
181 # the extra character with .. (two dots). That's why the "+ 2" in the formula below.
182 # Example: if we have a 21-long version number that we want to fit into a 10-long space,
183 # we have to remove 11 characters. But if we replace 11 characters with 2 characters, we'll
184 # end up with a 12-character long string. That's why we replace 12 characters with ..
185 REMOVE=`expr substr "$PKG_VER" 4 $[ ${#PKG_VER} - $VER_WIDTH + 2 ]`
186 PKG_VER=`echo ${PKG_VER/$REMOVE/..}`
187 fi
188
189 echo "$PKG_VER"
190 } # End of get_pkg_ver()
191
192 if [ 'x86_64' = $MACHINE -o 'i686' = $MACHINE -o 'i586' = $MACHINE ]; then
193 echo "`date -u '+%b %e %T'`: Machine is iX86 (or equivalent)" >> $LOGFILE
194 MACHINE=i586
195 BUILDTARGET=i586-pc-linux-gnu
196 CFLAGS="-O2 -march=i586 -pipe -fomit-frame-pointer"
197 CXXFLAGS="-O2 -march=i586 -pipe -fomit-frame-pointer"
198 C2FLAGS="-O2 -march=i586 -mtune=i586 -pipe -fomit-frame-pointer"
199 CXX2FLAGS="-O2 -march=i586 -mtune=i586 -pipe -fomit-frame-pointer"
200 else
201 echo "`date -u '+%b %e %T'`: Can't determine your architecture - $MACHINE" >> $LOGFILE
202 exit 1
203 fi
204
205 # Define immediately
206 stdumount() {
207 umount $BASEDIR/build/sys 2>/dev/null;
208 umount $BASEDIR/build/dev/shm 2>/dev/null;
209 umount $BASEDIR/build/dev/pts 2>/dev/null;
210 umount $BASEDIR/build/dev 2>/dev/null;
211 umount $BASEDIR/build/proc 2>/dev/null;
212 umount $BASEDIR/build/install/mnt 2>/dev/null;
213 umount $BASEDIR/build/usr/src/cache 2>/dev/null;
214 umount $BASEDIR/build/usr/src/ccache 2>/dev/null;
215 umount $BASEDIR/build/usr/src/config 2>/dev/null;
216 umount $BASEDIR/build/usr/src/doc 2>/dev/null;
217 umount $BASEDIR/build/usr/src/html 2>/dev/null;
218 umount $BASEDIR/build/usr/src/langs 2>/dev/null;
219 umount $BASEDIR/build/usr/src/lfs 2>/dev/null;
220 umount $BASEDIR/build/usr/src/log 2>/dev/null;
221 umount $BASEDIR/build/usr/src/src 2>/dev/null;
222 }
223
224 exiterror() {
225 stdumount
226 for i in `seq 0 7`; do
227 if ( losetup /dev/loop${i} 2>/dev/null | grep -q "/install/images" ); then
228 losetup -d /dev/loop${i} 2>/dev/null
229 fi;
230 done
231 echo -e "\nERROR: $*"
232 echo " Check $LOGFILE for errors if applicable"
233 exit 1
234 }
235
236 entershell() {
237 if [ ! -e $BASEDIR/build/usr/src/lfs/ ]; then
238 exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/"
239 fi
240 echo "Entering to a shell inside LFS chroot, go out with exit"
241 chroot $LFS /tools/bin/env -i HOME=/root TERM=$TERM PS1='\u:\w\$ ' \
242 PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
243 VERSION=$VERSION CONFIG_ROOT=$CONFIG_ROOT \
244 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
245 CFLAGS="$CF2LAGS" CXXFLAGS="$CXX2FLAGS" \
246 CCACHE_DIR=/usr/src/ccache \
247 CCACHE_HASHDIR=1 \
248 KVER=$KVER \
249 BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
250 KGCC="ccache /usr/bin/gcc" \
251 /tools/bin/bash
252 if [ $? -ne 0 ]; then
253 beautify message FAIL
254 exiterror "chroot error"
255 else
256 stdumount
257 fi
258 }
259
260 ############################################################################
261 # #
262 # Necessary shell functions #
263 # #
264 ############################################################################
265 #
266 # Common checking before entering the chroot and compilling
267 #
268 # Return:0 caller can continue
269 # :1 skip (nothing to do)
270 # or fail if no script file found
271 #
272 lfsmakecommoncheck()
273 {
274 # Script present?
275 if [ ! -f $BASEDIR/lfs/$1 ]; then
276 exiterror "No such file or directory: $BASEDIR/$1"
277 fi
278
279 local PKG_VER=`get_pkg_ver $BASEDIR/lfs/$1`
280 beautify make_pkg "$PKG_VER $*"
281
282 # Script slipped?
283 local i
284 for i in $SKIP_PACKAGE_LIST
285 do
286 if [ "$i" == "$1" ]; then
287 beautify result SKIP
288 return 1;
289 fi
290 done
291
292 echo -ne "`date -u '+%b %e %T'`: Building $* " >> $LOGFILE
293
294 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t " download >> $LOGFILE 2>&1
295 if [ $? -ne 0 ]; then
296 exiterror "Download error in $1"
297 fi
298
299 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t md5sum" md5 >> $LOGFILE 2>&1
300 if [ $? -ne 0 ]; then
301 exiterror "md5sum error in $1, check file in cache or signature"
302 fi
303
304 return 0 # pass all!
305 } # End of lfsmakecommoncheck()
306
307 lfsmake1() {
308 lfsmakecommoncheck $*
309 [ $? == 1 ] && return 0
310
311 local PKG_TIME_START=`date +%s`
312
313 cd $BASEDIR/lfs && make -f $* BUILDTARGET=$BUILDTARGET \
314 MACHINE=$MACHINE \
315 LFS_BASEDIR=$BASEDIR \
316 ROOT=$LFS \
317 KVER=$KVER \
318 MAKETUNING=$MAKETUNING \
319 install >> $LOGFILE 2>&1
320 local COMPILE_SUCCESS=$?
321 local PKG_TIME_END=`date +%s`
322
323 if [ $COMPILE_SUCCESS -ne 0 ]; then
324 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ]
325 exiterror "Building $*";
326 else
327 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
328 fi
329
330 return 0
331 }
332
333 lfsmake2() {
334 lfsmakecommoncheck $*
335 [ $? == 1 ] && return 0
336
337 local PKG_TIME_START=`date +%s`
338 chroot $LFS /tools/bin/env -i HOME=/root \
339 TERM=$TERM PS1='\u:\w\$ ' \
340 PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
341 VERSION=$VERSION \
342 CONFIG_ROOT=$CONFIG_ROOT \
343 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
344 CFLAGS="$C2FLAGS" CXXFLAGS="$CXX2FLAGS" \
345 CCACHE_DIR=/usr/src/ccache CCACHE_HASHDIR=1 \
346 KVER=$KVER MAKETUNING=$MAKETUNING \
347 BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
348 IPFVER="$IPFVER" \
349 /tools/bin/bash -x -c "cd /usr/src/lfs && \
350 make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
351 local COMPILE_SUCCESS=$?
352 local PKG_TIME_END=`date +%s`
353
354 if [ $COMPILE_SUCCESS -ne 0 ]; then
355 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ]
356 exiterror "Building $*";
357 else
358 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
359 fi
360
361 return 0
362 }
363
364 ipfiremake() {
365 lfsmakecommoncheck $*
366 [ $? == 1 ] && return 0
367
368 local PKG_TIME_START=`date +%s`
369 chroot $LFS /tools/bin/env -i HOME=/root \
370 TERM=$TERM PS1='\u:\w\$ ' \
371 PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin \
372 VERSION=$VERSION \
373 CONFIG_ROOT=$CONFIG_ROOT \
374 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
375 CFLAGS="$C2FLAGS" CXXFLAGS="$CXX2FLAGS" \
376 CCACHE_DIR=/usr/src/ccache CCACHE_HASHDIR=1 \
377 KVER=$KVER MAKETUNING=$MAKETUNING \
378 BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
379 IPFVER="$IPFVER" \
380 /bin/bash -x -c "cd /usr/src/lfs && \
381 make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
382
383 local COMPILE_SUCCESS=$?
384 local PKG_TIME_END=`date +%s`
385
386 if [ $COMPILE_SUCCESS -ne 0 ]; then
387 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ]
388 exiterror "Building $*";
389 else
390 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
391 fi
392 return 0
393 }
394
395 ipfiredist() {
396 if [ -f $BASEDIR/build/usr/src/lfs/$1 ]; then
397 echo "`date -u '+%b %e %T'`: Packaging $1" | tee -a $LOGFILE
398 chroot $LFS /tools/bin/env -i HOME=/root \
399 TERM=$TERM PS1='\u:\w\$ ' \
400 PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin \
401 VERSION=$VERSION \
402 CONFIG_ROOT=$CONFIG_ROOT \
403 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
404 CFLAGS="$C2FLAGS" CXXFLAGS="$CXX2FLAGS" \
405 CCACHE_DIR=/usr/src/ccache CCACHE_HASHDIR=1 \
406 KVER=$KVER IPFVER="$IPFVER" \
407 BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
408 /bin/bash -x -c "cd /usr/src/lfs && \
409 make -f $1 LFS_BASEDIR=/usr/src dist" >>$LOGFILE 2>&1
410 if [ $? -ne 0 ]; then
411 exiterror "Packaging $1"
412 fi
413 else
414 exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/$1"
415 fi
416 return 0
417 }
418
419 installmake() {
420 lfsmakecommoncheck $*
421 [ $? == 1 ] && return 0
422
423 local PKG_TIME_START=`date +%s`
424 chroot $LFS /tools/bin/env -i HOME=/root \
425 TERM=$TERM PS1='\u:\w\$ ' \
426 PATH=/opt/i586-uClibc/i586-linux-uclibc/bin:/opt/i586-uClibc/bin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin \
427 VERSION=$VERSION \
428 CONFIG_ROOT=$CONFIG_ROOT \
429 LFS_PASS="install" \
430 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
431 CFLAGS="-Os" CXXFLAGS="-Os" \
432 CCACHE_DIR=/usr/src/ccache CCACHE_HASHDIR=1 \
433 KVER=$KVER IPFVER="$IPFVER" \
434 BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
435 /bin/bash -x -c "cd /usr/src/lfs && \
436 make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
437
438 local COMPILE_SUCCESS=$?
439 local PKG_TIME_END=`date +%s`
440
441 if [ $COMPILE_SUCCESS -ne 0 ]; then
442 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ]
443 exiterror "Building $*";
444 else
445 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
446 fi
447 return 0
448 }
449
450 update_logs() {
451 tar cfz log/ipfire-logs-`date +'%Y-%m-%d-%H:%M'`.tgz log/_build.*
452 rm -f log/_build.*
453 }
454
455 batch_script() {
456 echo -ne "${BOLD}***This is our auto buildscript! Have fun...${NORMAL}\n"
457 update_logs
458 evaluate 1
459
460 if [ "$IPFIRE_REBUILD" -eq "0" ]; then
461 export IPFIRE_START_TIME=`date`
462 evaluate 1
463
464 echo -ne "### RUNNING SVN-UPDATE"
465 $0 svn update
466 evaluate 1 mail_me SVNUPDATE
467
468 echo "### EXPORT SOURCES"
469 $0 svn dist
470 evaluate 1 mail_me SVNDIST
471
472 echo "### RUNNING PREFETCH"
473 $0 downloadsrc | grep -q "md5 difference"
474 evaluate 1 mail_me PREFETCH
475 fi
476
477 echo "### RUNNING BUILD"
478 $0 build
479 evaluate 1 mail_me ERROR
480
481 echo "### UPLOADING ISO"
482 $0 upload iso
483 evaluate 1 mail_me ISO
484
485 echo -ne "### UPLOADING PAKS"
486 $0 upload paks
487 evaluate 1 mail_me PAKS
488
489 echo -n "${BOLD}***SUCCESS!${NORMAL}"
490 evaluate 0 mail_me SUCCESS
491 exit 0
492 }
493
494 watch_screen() {
495 echo -e "${BOLD}Exit with Ctrl+A, Ctrl+D.${NORMAL}"
496 sleep 0.5
497 screen -x ipfire
498 }
499
500 mail_me() {
501 chmod 755 tools/sendEmail
502 ATTACHMENT=/tmp/ipfire-build-logs-R$SVN_REVISION.tar.gz
503 case "$1" in
504 success)
505 SUBJECT="SUCCESS: IPFIRE-BUILD R$SVN_REVISION on `hostname`"
506 cat <<END > /tmp/ipfire_mail_body
507 Building IPFire on `hostname` in Revision $SVN_REVISION was successfull!
508 You can find the ISO on your ftp server.
509
510 Statistics:
511 -----------
512 Started: $IPFIRE_START_TIME
513 Finished: `date`
514
515 Best Regards
516 Your IPFire-Build-Script
517
518 END
519 echo -ne "${BOLD}***Sending success message${NORMAL}"
520 ;;
521 *)
522 SUBJECT="ERROR $1: IPFIRE-BUILD R$SVN_REVISION on `hostname`"
523 cat <<END > /tmp/ipfire_mail_body
524 When I was building IPFire on `hostname`, I have found an ERROR with name $1!
525 Here you can see the logs and detect the reason for this error.
526
527 Best Regards
528 Your IPFire-Build-Script
529
530
531 Here is a summary... The full logs are in the attachment.
532 ---------------------------------------------------------
533
534 `tail log/_*`
535 END
536 echo -ne "${BOLD}***Sending error message${NORMAL}"
537 ;;
538 esac
539 tar cfz $ATTACHMENT log/_build*
540 cat /tmp/ipfire_mail_body | tools/sendEmail -q \
541 -f $IPFIRE_MAIL_FROM \
542 -t $IPFIRE_MAIL_REPORT \
543 -u $SUBJECT \
544 -s $IPFIRE_MAIL_SERVER:25 \
545 -xu $IPFIRE_MAIL_USER \
546 -xp $IPFIRE_MAIL_PASS \
547 -l log/_build.mail.log \
548 -a $ATTACHMENT # -v
549 if [ "$?" -eq "0" ]; then
550 beautify message DONE
551 else
552 beautify message FAIL
553 fi
554 rm -f /tmp/ipfire_mail_body $ATTACHMENT
555 }
556
557 make_config() {
558 clear
559 echo -e "${BOLD}***This will create your configuration...${NORMAL}"
560 echo -ne "***If your are ready press <ENTER>!"
561 read
562 clear
563 echo -ne "***The buildscript will create a full iso image.\n"
564 echo -ne "***If you want to skip any package please enter its name here seperated with space.\n"
565 echo -ne "Actually in the list are: $SKIP_PACKAGE_LIST\n"
566 echo -ne "Do you want to change this? (y/N) "
567 read YESNO
568 if [ "$YESNO" == "y" ]; then
569 echo -ne "Please type: "
570 read SKIP_PACKAGE_LIST
571 echo -ne "You entered: $SKIP_PACKAGE_LIST\n"
572 fi
573
574 clear
575 echo -ne "***When you have compiled successfully, there is the possibility\n"
576 echo -ne "***to upload the iso image to a ftp server.\n"
577 echo -ne "***If the url is empty there will be no upload.\n"
578 echo -ne "Actually there is: $FTP_ISO_URL\n"
579 echo -ne "Do you want to change this? (y/N) "
580 read YESNO
581 if [ "$YESNO" == "y" ]; then
582 echo -ne "Please type the url: "
583 read FTP_ISO_URL
584 echo -ne "Please type the path: "
585 read FTP_ISO_PATH
586 echo -ne "Please type the username: "
587 read FTP_ISO_USER
588 echo -ne "Please type the password (hidden): "
589 read -s FTP_ISO_PASS
590
591 fi
592
593 clear
594 echo -ne "***When you add some new software you can easyly\n"
595 echo -ne "***upload the source code to our repository server.\n"
596 echo -ne "***If the url is empty there will be no upload.\n"
597 echo -ne "Actually there is: $FTP_CACHE_URL\n"
598 echo -ne "Do you want to change this? (y/N) "
599 read YESNO
600 if [ "$YESNO" == "y" ]; then
601 echo -ne "Please type the url: "
602 read FTP_CACHE_URL
603 echo -ne "Please type the path: "
604 read FTP_CACHE_PATH
605 echo -ne "Please type the username: "
606 read FTP_CACHE_USER
607 echo -ne "Please type the password (hidden): "
608 read -s FTP_CACHE_PASS
609
610 fi
611
612 clear
613 echo -ne "***If there are some important messages you\n"
614 echo -ne "***can get a notification mail.\n"
615 echo -ne "***Please type one ore more email adresses (seperated by comma).\n"
616 echo -ne "Actually there is: $MAIL_TO\n"
617 echo -ne "Do you want to change this? (y/N) "
618 read YESNO
619 if [ "$YESNO" == "y" ]; then
620 echo -ne "Please type: "
621 read MAIL_TO
622 echo -ne "You should enter a mail server to login...\n"
623 echo -ne "Please type the url: "
624 read MAIL_SERVER
625 echo -ne "Please type the username: "
626 read MAIL_USER
627 echo -ne "Please type the password (hidden): "
628 read -s MAIL_PASS
629
630 fi
631 echo -ne "${BOLD}***Saving...${NORMAL}"
632 cat <<END > $BASEDIR/.config
633 ### iso server
634 FTP_ISO_URL=$FTP_ISO_URL
635 FTP_ISO_PATH=$FTP_ISO_PATH
636 FTP_ISO_USER=$FTP_ISO_USER
637 FTP_ISO_PASS=$FTP_ISO_PASS
638 ### cache server
639 FTP_CACHE_URL=$FTP_CACHE_URL
640 FTP_CACHE_PATH=$FTP_CACHE_PATH
641 FTP_CACHE_USER=$FTP_CACHE_USER
642 FTP_CACHE_PASS=$FTP_CACHE_PASS
643 ### mail reports
644 MAIL_TO="$MAIL_TO"
645 MAIL_SERVER=$MAIL_SERVER
646 MAIL_USER=$MAIL_USER
647 MAIL_PASS=$MAIL_PASS
648 ### misc
649 SKIP_PACKAGE_LIST="$SKIP_PACKAGE_LIST"
650 END
651 beautify message DONE
652 }
653
654 compile_tftpd() {
655 mkdir $BASEDIR/tmp
656 tar xvfz $BASEDIR/cache/tftp-hpa-0.42.tar.gz -C $BASEDIR/tmp
657 cd $BASEDIR/tmp/tftp-hpa-*
658 ./configure --prefix=/ipfire/trunk/tools/ \
659 --sbindir=/ipfire/trunk/tools/ --disable-nls
660 make
661 install -c tftpd/tftpd $BASEDIR/tools/in.tftpd
662 cd -
663 rm -rf $BASEDIR/tmp/tftp-hpa-*
664 }
665
666 start_tftpd() {
667 if [ ! -e $BASEDIR/tools/in.tftpd ]; then
668 compile_tftpd
669 fi
670 reload_tftpd
671 if [ "$?" == "0" ]; then
672 $BASEDIR/tools/in.tftpd -l -s $BASEDIR/tftpboot
673 beautify message DONE
674 else
675 echo -en "You don not have a pxe boot image in your base directory.\nPlease compile first."
676 beautify message FAIL
677 exit 1
678 fi
679 }
680
681 stop_tftpd() {
682 echo -n "Stopping TFTPD..."
683 killall in.tftpd >/dev/null 2>&1
684 sleep 3
685 killall -9 in.tftp >/dev/null 2>&1
686 beautify message DONE
687 }
688
689 reload_tftpd() {
690 if [ -e $BASEDIR/ipfire-$VERSION-pxe-$MACHINE.tgz ]; then
691 mkdir -p $BASEDIR/tftpboot
692 tar xfz $BASEDIR/ipfire-$VERSION-pxe-$MACHINE.tgz -C $BASEDIR/tftpboot
693 return 0
694 fi
695 return 1
696 }