Contents of /branches/R11-stable/include/mtools.sminc
Parent Directory | Revision Log
Revision 8809 -
(show annotations)
(download)
Fri Jul 29 14:40:23 2011 UTC (13 years, 3 months ago) by niro
Original Path: branches/magellan-next/include/mtools.sminc
File size: 16282 byte(s)
Fri Jul 29 14:40:23 2011 UTC (13 years, 3 months ago) by niro
Original Path: branches/magellan-next/include/mtools.sminc
File size: 16282 byte(s)
-fixed a spelling typo
1 | # $Header: /magellan-cvs/smage/include/mtools.sminc,v 1.39 2008/04/20 08:28:23 niro Exp $ |
2 | # some special build tools |
3 | |
4 | # automatical inherit mtools.minc |
5 | # this will provide the service management functions |
6 | INHERITS="${INHERITS} mtools" |
7 | |
8 | # get the pname right with splitpackages |
9 | mpname() |
10 | { |
11 | local pname="${PNAME}" |
12 | [[ ! -z ${SPLIT_PACKAGE_BASE} ]] && pname="${SPLIT_PACKAGE_BASE}" |
13 | |
14 | echo "${pname}" |
15 | } |
16 | |
17 | # installs initscripts |
18 | # minstallrc /path/to/rc-script {destfilename} |
19 | minstallrc() |
20 | { |
21 | local rcscript |
22 | local file |
23 | |
24 | [[ -z "$1" ]] && die "No initscript given" |
25 | |
26 | # if no fullpath given use file from sourcedir |
27 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
28 | then |
29 | file="${SOURCEDIR}/$(mpname)/$1" |
30 | else |
31 | file="$1" |
32 | fi |
33 | |
34 | if [[ -n "$2" ]] |
35 | then |
36 | rcscript="$2" |
37 | else |
38 | rcscript="$(basename ${file})" |
39 | fi |
40 | |
41 | # needed directory |
42 | install -d ${BINDIR}/etc/rc.d/init.d || die |
43 | |
44 | # install our initscript |
45 | install -v -m 0755 -o root -g root ${file} ${BINDIR}/etc/rc.d/init.d/${rcscript} || die |
46 | } |
47 | |
48 | # installs environment files |
49 | # minstallenv /path/to/envdfile {destfilename} |
50 | minstallenv() |
51 | { |
52 | local envdfile |
53 | local file |
54 | |
55 | [[ -z "$1" ]] && die "No envd file given" |
56 | |
57 | # if no fullpath given use file from sourcedir |
58 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
59 | then |
60 | file="${SOURCEDIR}/$(mpname)/$1" |
61 | else |
62 | file="$1" |
63 | fi |
64 | |
65 | if [[ -n "$2" ]] |
66 | then |
67 | envdfile="$2" |
68 | else |
69 | envdfile="$(basename ${file})" |
70 | fi |
71 | |
72 | # needed directory |
73 | install -d ${BINDIR}/etc/env.d || die |
74 | |
75 | # install our envfile |
76 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/env.d/${envdfile} || die |
77 | } |
78 | |
79 | # installs system configuration files |
80 | # minstallconf /path/to/confdfile {destfilename} |
81 | minstallconf() |
82 | { |
83 | local confdfile |
84 | local file |
85 | |
86 | [[ -z "$1" ]] && die "No confd file given" |
87 | |
88 | # if no fullpath given use file from sourcedir |
89 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
90 | then |
91 | file="${SOURCEDIR}/$(mpname)/$1" |
92 | else |
93 | file="$1" |
94 | fi |
95 | |
96 | if [[ -n "$2" ]] |
97 | then |
98 | confdfile="$2" |
99 | else |
100 | confdfile="$(basename ${file})" |
101 | fi |
102 | |
103 | # needed directory |
104 | install -d ${BINDIR}/etc/conf.d || die |
105 | |
106 | # install our configfile |
107 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/conf.d/${confdfile} || die |
108 | } |
109 | |
110 | # installs system configuration files to etc |
111 | # minstalletc /path/to/etcfile {destfilename} {destdir path} |
112 | minstalletc() |
113 | { |
114 | local etcfile |
115 | local file |
116 | local destdir |
117 | |
118 | [[ -z "$1" ]] && die "No etc file given" |
119 | |
120 | # if no fullpath given use file from sourcedir |
121 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
122 | then |
123 | file="${SOURCEDIR}/$(mpname)/$1" |
124 | else |
125 | file="$1" |
126 | fi |
127 | |
128 | if [[ -n "$2" ]] |
129 | then |
130 | etcfile="$2" |
131 | else |
132 | etcfile="$(basename ${file})" |
133 | fi |
134 | |
135 | if [[ -n "$3" ]] |
136 | then |
137 | destdir="$3" |
138 | else |
139 | destdir="/etc" |
140 | fi |
141 | |
142 | # needed directory |
143 | install -d ${BINDIR}/${destdir} || die |
144 | |
145 | # install our configfile |
146 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/${destdir}/${etcfile} || die |
147 | } |
148 | |
149 | minstalludevrule() |
150 | { |
151 | local udevrule |
152 | local file |
153 | |
154 | [[ -z "$1" ]] && die "No udev rule given" |
155 | |
156 | # if no fullpath given use file from sourcedir |
157 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
158 | then |
159 | file="${SOURCEDIR}/$(mpname)/$1" |
160 | else |
161 | file="$1" |
162 | fi |
163 | |
164 | if [[ -n "$2" ]] |
165 | then |
166 | udevrule="$2" |
167 | else |
168 | udevrule="$(basename ${file})" |
169 | fi |
170 | |
171 | # needed directory |
172 | install -d ${BINDIR}/etc/udev/rules.d || die |
173 | |
174 | # install our udev rule |
175 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/udev/rules.d/${udevrule} || die |
176 | } |
177 | |
178 | minstalludevhelper() |
179 | { |
180 | local udevhelper |
181 | local file |
182 | |
183 | [[ -z "$1" ]] && die "No udev helper given" |
184 | |
185 | # if no fullpath given use file from sourcedir |
186 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
187 | then |
188 | file="${SOURCEDIR}/$(mpname)/$1" |
189 | else |
190 | file="$1" |
191 | fi |
192 | |
193 | if [[ -n "$2" ]] |
194 | then |
195 | udevhelper="$2" |
196 | else |
197 | udevhelper="$(basename ${file})" |
198 | fi |
199 | |
200 | # needed directory |
201 | install -d ${BINDIR}/lib/udev || die |
202 | |
203 | # install our udev-helper |
204 | install -v -m 0755 -o root -g root ${file} ${BINDIR}/lib/udev/${udevhelper} || die |
205 | } |
206 | |
207 | minstallhalinformation() |
208 | { |
209 | local halrule |
210 | local file |
211 | |
212 | [[ -z "$1" ]] && die "No hal rule given" |
213 | |
214 | # if no fullpath given use file from sourcedir |
215 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
216 | then |
217 | file="${SOURCEDIR}/$(mpname)/$1" |
218 | else |
219 | file="$1" |
220 | fi |
221 | |
222 | if [[ -n "$2" ]] |
223 | then |
224 | halrule="$2" |
225 | else |
226 | halrule="$(basename ${file})" |
227 | fi |
228 | |
229 | # needed directory |
230 | install -d ${BINDIR}/usr/share/hal/fdi/information/20thirdparty || die |
231 | |
232 | # install our udev rule |
233 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/usr/share/hal/fdi/information/20thirdparty/${halrule} || die |
234 | } |
235 | |
236 | minstallhalpolicy() |
237 | { |
238 | local halrule |
239 | local file |
240 | |
241 | [[ -z "$1" ]] && die "No hal rule given" |
242 | |
243 | # if no fullpath given use file from sourcedir |
244 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
245 | then |
246 | file="${SOURCEDIR}/$(mpname)/$1" |
247 | else |
248 | file="$1" |
249 | fi |
250 | |
251 | if [[ -n "$2" ]] |
252 | then |
253 | halrule="$2" |
254 | else |
255 | halrule="$(basename ${file})" |
256 | fi |
257 | |
258 | # needed directory |
259 | install -d ${BINDIR}/usr/share/hal/fdi/policy/20thirdparty || die |
260 | |
261 | # install our udev rule |
262 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/usr/share/hal/fdi/policy/20thirdparty/${halrule} || die |
263 | } |
264 | |
265 | minstallhalpreprobe() |
266 | { |
267 | local halrule |
268 | local file |
269 | |
270 | [[ -z "$1" ]] && die "No hal rule given" |
271 | |
272 | # if no fullpath given use file from sourcedir |
273 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
274 | then |
275 | file="${SOURCEDIR}/$(mpname)/$1" |
276 | else |
277 | file="$1" |
278 | fi |
279 | |
280 | if [[ -n "$2" ]] |
281 | then |
282 | halrule="$2" |
283 | else |
284 | halrule="$(basename ${file})" |
285 | fi |
286 | |
287 | # needed directory |
288 | install -d ${BINDIR}/usr/share/hal/fdi/preprobe/10osvendor || die |
289 | |
290 | # install our udev rule |
291 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/usr/share/hal/fdi/preprobe/10osvendor/${halrule} || die |
292 | } |
293 | |
294 | # install man files to appropiate dirs |
295 | # minstallman /path/to/manfile.foo |
296 | minstallman() |
297 | { |
298 | local manfile |
299 | local mandir |
300 | local file |
301 | |
302 | [[ -z "$@" ]] && die "No man file given" |
303 | |
304 | for file in $@ |
305 | do |
306 | manfile="$(basename ${file})" |
307 | mandir="man${manfile##*.}" |
308 | |
309 | install -d ${BINDIR}/usr/share/man/${mandir} || die |
310 | install -v -m0644 ${file} ${BINDIR}/usr/share/man/${mandir}/${manfile} || die |
311 | done |
312 | } |
313 | |
314 | # install info files to appropiate dirs |
315 | # minstallinfo /path/to/infofile.foo |
316 | minstallinfo() |
317 | { |
318 | local file |
319 | |
320 | [[ -z "$@" ]] && die "No info file given" |
321 | |
322 | for file in $@ |
323 | do |
324 | install -d ${BINDIR}/usr/share/info || die |
325 | install -v -m0644 ${file} ${BINDIR}/usr/share/info/$(basename ${file}) || die |
326 | done |
327 | } |
328 | |
329 | # install html files to appropiate dirs |
330 | # minstallhtml /path/to/infofile.foo |
331 | minstallhtml() |
332 | { |
333 | local file |
334 | local subfile |
335 | local prefix |
336 | local subprefix |
337 | |
338 | # handle prefix |
339 | case "$1" in |
340 | --prefix|-p) shift; prefix="$1"; shift ;; |
341 | esac |
342 | |
343 | [[ -z "$@" ]] && die "No html file given" |
344 | |
345 | for file in $@ |
346 | do |
347 | install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/html${prefix} || die |
348 | |
349 | if [[ -d ${file} ]] |
350 | then |
351 | for subfile in ${file}/* |
352 | do |
353 | subprefix="$(dirname ${subfile/$(dirname ${file})/})" |
354 | subprefix="${prefix}${subprefix}/" |
355 | |
356 | minstallhtml --prefix ${subprefix} ${subfile} || die |
357 | done |
358 | else |
359 | install -v -m0644 ${file} ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/html/${prefix}$(basename ${file}) || die |
360 | fi |
361 | done |
362 | } |
363 | |
364 | # install pixmaps to appropiate dirs |
365 | # minstallpixmap srcname destname {/path/to} |
366 | minstallpixmap() |
367 | { |
368 | local file |
369 | local destdir |
370 | local destfile |
371 | |
372 | [[ -z "$1" ]] && die "No pixmap given" |
373 | |
374 | # if no fullpath given use file from sourcedir |
375 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
376 | then |
377 | file="${SOURCEDIR}/$(mpname)/$1" |
378 | else |
379 | file="$1" |
380 | fi |
381 | |
382 | if [[ -n "$2" ]] |
383 | then |
384 | destfile="$2" |
385 | else |
386 | destfile="$(basename ${file})" |
387 | fi |
388 | |
389 | if [[ -n "$3" ]] |
390 | then |
391 | destdir="$3" |
392 | else |
393 | destdir="/usr/share/pixmaps" |
394 | fi |
395 | |
396 | # needed directory |
397 | install -d ${BINDIR}/${destdir} || die |
398 | |
399 | # install our pixmap |
400 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/${destdir}/${destfile} || die |
401 | } |
402 | |
403 | # installs pam configuration files |
404 | # minstallpam /path/to/pamfile {destfilename} |
405 | minstallpam() |
406 | { |
407 | local pamfile |
408 | local file |
409 | |
410 | [[ -z "$1" ]] && die "No pam file given" |
411 | |
412 | # if no fullpath given use file from sourcedir |
413 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
414 | then |
415 | file="${SOURCEDIR}/$(mpname)/$1" |
416 | else |
417 | file="$1" |
418 | fi |
419 | |
420 | if [[ -n "$2" ]] |
421 | then |
422 | pamfile="$2" |
423 | else |
424 | pamfile="$(basename ${file})" |
425 | fi |
426 | |
427 | # needed directory |
428 | install -d ${BINDIR}/etc/pam.d || die |
429 | |
430 | # install our configfile |
431 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/pam.d/${pamfile} || die |
432 | } |
433 | |
434 | # installs cronjobs |
435 | # minstallcron [hourly|daily|weekly|monthly] /path/to/cronfile {destfilename} |
436 | minstallcron() |
437 | { |
438 | local cronfile |
439 | local loop |
440 | local file |
441 | |
442 | [[ -z "$1" ]] && die "No loop rythem given [hourly|daily|weekly|monthly]" |
443 | [[ -z "$2" ]] && die "No cronfile given" |
444 | |
445 | loop="$1" |
446 | |
447 | # if no fullpath given use file from sourcedir |
448 | if [[ -z $(dirname $2) ]] || [[ $(dirname $2) = . ]] |
449 | then |
450 | file="${SOURCEDIR}/$(mpname)/$2" |
451 | else |
452 | file="$2" |
453 | fi |
454 | |
455 | if [[ -n "$3" ]] |
456 | then |
457 | cronfile="$3" |
458 | else |
459 | cronfile="$(basename ${file})" |
460 | fi |
461 | |
462 | # needed directory |
463 | install -m0750 -d ${BINDIR}/etc/cron.${loop} || die |
464 | |
465 | # install our cronfile |
466 | install -v -m 0750 -o root -g root ${file} ${BINDIR}/etc/cron.${loop}/${cronfile} || die |
467 | } |
468 | |
469 | |
470 | # installs logrotate configuration files |
471 | # minstalllog /path/to/logrotatefile {destfilename} |
472 | minstalllog() |
473 | { |
474 | local logfile |
475 | local file |
476 | |
477 | [[ -z "$1" ]] && die "No logrotate file given" |
478 | |
479 | # if no fullpath given use file from sourcedir |
480 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
481 | then |
482 | file="${SOURCEDIR}/$(mpname)/$1" |
483 | else |
484 | file="$1" |
485 | fi |
486 | |
487 | if [[ -n "$2" ]] |
488 | then |
489 | logfile="$2" |
490 | else |
491 | logfile="$(basename ${file})" |
492 | fi |
493 | |
494 | # needed directory |
495 | install -d ${BINDIR}/etc/logrotate.d || die |
496 | |
497 | # install our configfile |
498 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/logrotate.d/${logfile} || die |
499 | } |
500 | |
501 | |
502 | # installs given directories |
503 | # minstalldir /path/to/dest/dir {/path/to/dest/dirN} |
504 | minstalldir() |
505 | { |
506 | local argv="$@" |
507 | local dest |
508 | |
509 | [[ -z ${argv} ]] && die "No dest dir given" |
510 | for dest in ${argv} |
511 | do |
512 | [[ -d ${BINDIR}${dest} ]] && continue |
513 | install -v -d ${BINDIR}/${dest} || die |
514 | done |
515 | } |
516 | |
517 | |
518 | # install files to given path (defaults to /usr/bin) |
519 | # minstallfile {-s} /path/to/file {/path/to/dest} |
520 | minstallfile() |
521 | { |
522 | local file |
523 | local dest |
524 | |
525 | [[ -z $1 ]] && die "No etc file given" |
526 | |
527 | if [[ $1 = -s ]] |
528 | then |
529 | file="${SOURCEDIR}/$(mpname)/$2" |
530 | dest="$3" |
531 | if [[ -z $3 ]] |
532 | then |
533 | dest=/usr/bin |
534 | install -d ${BINDIR}/${dest} || die |
535 | fi |
536 | else |
537 | file="$1" |
538 | dest="$2" |
539 | if [[ -z $2 ]] |
540 | then |
541 | dest=/usr/bin |
542 | install -d ${BINDIR}/${dest} || die |
543 | fi |
544 | fi |
545 | |
546 | # install our configfile |
547 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/${dest} || die |
548 | } |
549 | |
550 | # installs executables to given path |
551 | # minstallexec {-s} /path/to/exec {/path/to/dest} |
552 | minstallexec() |
553 | { |
554 | local file |
555 | local dest |
556 | |
557 | [[ -z $1 ]] && die "No file given" |
558 | |
559 | if [[ $1 = -s ]] |
560 | then |
561 | file="${SOURCEDIR}/$(mpname)/$2" |
562 | dest="$3" |
563 | if [[ -z $3 ]] |
564 | then |
565 | dest=/usr/bin |
566 | install -d ${BINDIR}/${dest} || die |
567 | fi |
568 | else |
569 | file="$1" |
570 | dest="$2" |
571 | if [[ -z $2 ]] |
572 | then |
573 | dest=/usr/bin |
574 | install -d ${BINDIR}/${dest} || die |
575 | fi |
576 | fi |
577 | |
578 | # install our configfile |
579 | install -v -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die |
580 | } |
581 | |
582 | # installs executables to given path |
583 | # minstalllib {-s} /path/to/exec {/path/to/dest} |
584 | minstalllib() |
585 | { |
586 | local file |
587 | local dest |
588 | local verbose="-v" |
589 | |
590 | # check for busybox as it doesn'tz support 'ln -v' |
591 | [[ $(readlink $(which ln)) = */busybox ]] && verbose="" |
592 | |
593 | [[ -z $1 ]] && die "No file given" |
594 | |
595 | if [[ $1 = -s ]] |
596 | then |
597 | file="${SOURCEDIR}/$(mpname)/$2" |
598 | dest="$3" |
599 | if [[ -z $3 ]] |
600 | then |
601 | dest=/usr/$(mlibdir) |
602 | install -d ${BINDIR}/${dest} || die |
603 | fi |
604 | else |
605 | file="$1" |
606 | dest="$2" |
607 | if [[ -z $2 ]] |
608 | then |
609 | dest=/usr/$(mlibdir) |
610 | install -d ${BINDIR}/${dest} || die |
611 | fi |
612 | fi |
613 | |
614 | # install our library |
615 | install -v -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die |
616 | |
617 | # create libtool symlinks |
618 | # 1. - library.so.1.0.0 -> library.so.1.0 |
619 | if [ "${file%.*}" != *.so ] |
620 | then |
621 | ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*}) |
622 | fi |
623 | # 2. - library.so.1.0.0 -> library.so.1 |
624 | if [ "${file%.*.*}" != *.so ] |
625 | then |
626 | ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*.*}) |
627 | fi |
628 | } |
629 | |
630 | mcopy() |
631 | { |
632 | local source="$1" |
633 | local dest="$2" |
634 | local opts |
635 | |
636 | # recursive |
637 | if [[ $1 = -r ]] || [[ $1 = -R ]] |
638 | then |
639 | opts="--recursive" |
640 | source="$2" |
641 | dest="$3" |
642 | fi |
643 | |
644 | # recursive |
645 | if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]] |
646 | then |
647 | opts="--recursive --force" |
648 | source="$2" |
649 | dest="$3" |
650 | fi |
651 | |
652 | [[ -z ${source} ]] && die "No source given." |
653 | [[ -z ${dest} ]] && die "No dest given." |
654 | |
655 | cp -v ${opts} ${source} ${BINDIR}/${dest} || die |
656 | } |
657 | |
658 | mmove() |
659 | { |
660 | local source="$1" |
661 | local dest="$2" |
662 | local opts |
663 | |
664 | # force |
665 | if [[ $1 = -f ]] |
666 | then |
667 | opts="--force" |
668 | source="$2" |
669 | dest="$3" |
670 | fi |
671 | |
672 | [[ -z ${source} ]] && die "No source given." |
673 | [[ -z ${dest} ]] && die "No dest given." |
674 | |
675 | mv -v ${opts} ${source} ${BINDIR}/${dest} || die |
676 | } |
677 | |
678 | # mark directories undeletable |
679 | mkeepdir() |
680 | { |
681 | local keepdir |
682 | [[ -z "$1" ]] && die "No directory given" |
683 | |
684 | keepdir="$1" |
685 | install -v -d ${BINDIR}/${keepdir} || die |
686 | touch ${BINDIR}/${keepdir}/.keep || die |
687 | } |
688 | |
689 | # creates empty files |
690 | memptyfile() |
691 | { |
692 | local file |
693 | local path |
694 | |
695 | [[ -z "$1" ]] && die "No file given" |
696 | |
697 | file="$1" |
698 | path="$(dirname ${file})" |
699 | |
700 | install -d ${BINDIR}/${path} || die |
701 | touch ${BINDIR}/${file} || die |
702 | } |
703 | |
704 | mchown() |
705 | { |
706 | local owner="$1" |
707 | local path="$2" |
708 | local recursive |
709 | |
710 | # recursive |
711 | if [[ $1 = -r ]] || [[ $1 = -R ]] |
712 | then |
713 | local recursive="--recursive" |
714 | local owner="$2" |
715 | local path="$3" |
716 | fi |
717 | |
718 | [[ -z ${owner} ]] && die "No owner given." |
719 | [[ -z ${path} ]] && die "No path given." |
720 | |
721 | chown -v ${recursive} ${owner} ${BINDIR}/${path} || die |
722 | } |
723 | |
724 | mchmod() |
725 | { |
726 | local posix="$1" |
727 | local path="$2" |
728 | local recursive |
729 | |
730 | # recursive |
731 | if [[ $1 = -r ]] || [[ $1 = -R ]] |
732 | then |
733 | local recursive="--recursive" |
734 | local posix="$2" |
735 | local path="$3" |
736 | fi |
737 | |
738 | [[ -z ${posix} ]] && die "No posix given." |
739 | [[ -z ${path} ]] && die "No path given." |
740 | |
741 | chmod -v ${recursive} ${posix} ${BINDIR}/${path} || die |
742 | } |
743 | |
744 | mlink() |
745 | { |
746 | local symlink="$1" |
747 | local pathto="$2" |
748 | local verbose="-v" |
749 | |
750 | # check for busybox as it doesn'tz support 'ln -v' |
751 | [[ $(readlink $(which ln)) = */busybox ]] && verbose="" |
752 | |
753 | [[ -z ${symlink} ]] && die "No symlink given." |
754 | [[ -z ${pathto} ]] && die "No path given." |
755 | |
756 | ln ${verbose} -snf ${symlink} ${BINDIR}/${pathto} || die |
757 | } |
758 | |
759 | # installs systemd units |
760 | # minstallunit /path/to/unit-file {destfilename} |
761 | minstallunit() |
762 | { |
763 | local unit |
764 | local file |
765 | |
766 | [[ -z "$1" ]] && die "No unit given" |
767 | |
768 | # if no fullpath given use file from sourcedir |
769 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
770 | then |
771 | file="${SOURCEDIR}/$(mpname)/$1" |
772 | else |
773 | file="$1" |
774 | fi |
775 | |
776 | if [[ -n "$2" ]] |
777 | then |
778 | unit="$2" |
779 | else |
780 | unit="$(basename ${file})" |
781 | fi |
782 | |
783 | # needed directory |
784 | install -d ${BINDIR}/lib/systemd/system || die |
785 | |
786 | # install our initscript |
787 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/lib/systemd/system/${unit} || die |
788 | } |
789 | |
790 | # installs systemd tmp configs to /etc/tmpfiles.d |
791 | # minstalltmp /path/to/tmpdfile {destfilename} |
792 | minstalltmp() |
793 | { |
794 | local tmpdfile |
795 | local file |
796 | |
797 | [[ -z "$1" ]] && die "No tmpd file given" |
798 | |
799 | # if no fullpath given use file from sourcedir |
800 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
801 | then |
802 | file="${SOURCEDIR}/$(mpname)/$1" |
803 | else |
804 | file="$1" |
805 | fi |
806 | |
807 | if [[ -n "$2" ]] |
808 | then |
809 | tmpdfile="$2" |
810 | else |
811 | tmpdfile="$(basename ${file})" |
812 | fi |
813 | |
814 | # needed directory |
815 | install -d ${BINDIR}/etc/tmpfiles.d || die |
816 | |
817 | # install our tmpdfile |
818 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/tmpfiles.d/${tmpdfile} || die |
819 | } |
820 | |
821 | mclearconfig() |
822 | { |
823 | local confdir |
824 | local prefix="${BINDIR}" |
825 | [[ -z ${MCONFIG} ]] && die "No \$MCONFIG given!" |
826 | |
827 | # no bindir prefix if requested |
828 | case $1 in |
829 | -b|--no-bindir) prefix="";; |
830 | esac |
831 | |
832 | confdir="$(dirname ${MCONFIG})" |
833 | if [[ ! -d ${prefix}/${confdir} ]] |
834 | then |
835 | install -d ${prefix}/${confdir} || die |
836 | fi |
837 | : > ${prefix}/${MCONFIG} |
838 | } |
839 | |
840 | maddconfig() |
841 | { |
842 | local argv="$1" |
843 | local confdir |
844 | local prefix="${BINDIR}" |
845 | |
846 | [[ -z ${MCONFIG} ]] && die "No \$MCONFIG given!" |
847 | |
848 | # no bindir prefix if requested |
849 | case $1 in |
850 | -b|--no-bindir) prefix=""; argv="$2" ;; |
851 | esac |
852 | |
853 | [[ -z ${argv} ]] && die "No argument given!" |
854 | |
855 | confdir="$(dirname ${MCONFIG})" |
856 | if [[ ! -d ${prefix}/${confdir} ]] |
857 | then |
858 | install -d ${prefix}/${confdir} || die |
859 | fi |
860 | echo "${argv}" >> ${prefix}/${MCONFIG} || die |
861 | } |