5 |
# this will provide the service management functions |
# this will provide the service management functions |
6 |
INHERITS="${INHERITS} mtools" |
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 |
# installs initscripts |
18 |
# minstallrc /path/to/rc-script {destfilename} |
# minstallrc /path/to/rc-script {destfilename} |
19 |
minstallrc() |
minstallrc() |
26 |
# if no fullpath given use file from sourcedir |
# if no fullpath given use file from sourcedir |
27 |
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
28 |
then |
then |
29 |
file="${SOURCEDIR}/${PNAME}/$1" |
file="${SOURCEDIR}/$(mpname)/$1" |
30 |
else |
else |
31 |
file="$1" |
file="$1" |
32 |
fi |
fi |
57 |
# if no fullpath given use file from sourcedir |
# if no fullpath given use file from sourcedir |
58 |
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
59 |
then |
then |
60 |
file="${SOURCEDIR}/${PNAME}/$1" |
file="${SOURCEDIR}/$(mpname)/$1" |
61 |
else |
else |
62 |
file="$1" |
file="$1" |
63 |
fi |
fi |
88 |
# if no fullpath given use file from sourcedir |
# if no fullpath given use file from sourcedir |
89 |
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
90 |
then |
then |
91 |
file="${SOURCEDIR}/${PNAME}/$1" |
file="${SOURCEDIR}/$(mpname)/$1" |
92 |
else |
else |
93 |
file="$1" |
file="$1" |
94 |
fi |
fi |
120 |
# if no fullpath given use file from sourcedir |
# if no fullpath given use file from sourcedir |
121 |
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
122 |
then |
then |
123 |
file="${SOURCEDIR}/${PNAME}/$1" |
file="${SOURCEDIR}/$(mpname)/$1" |
124 |
else |
else |
125 |
file="$1" |
file="$1" |
126 |
fi |
fi |
150 |
{ |
{ |
151 |
local udevrule |
local udevrule |
152 |
local file |
local file |
153 |
|
local udevrulesddir="/usr/lib/udev/rules.d" |
154 |
|
|
155 |
[[ -z "$1" ]] && die "No udev rule given" |
[[ -z "$1" ]] && die "No udev rule given" |
156 |
|
|
157 |
# if no fullpath given use file from sourcedir |
# if no fullpath given use file from sourcedir |
158 |
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
159 |
then |
then |
160 |
file="${SOURCEDIR}/${PNAME}/$1" |
file="${SOURCEDIR}/$(mpname)/$1" |
161 |
else |
else |
162 |
file="$1" |
file="$1" |
163 |
fi |
fi |
170 |
fi |
fi |
171 |
|
|
172 |
# needed directory |
# needed directory |
173 |
install -d ${BINDIR}/etc/udev/rules.d || die |
install -d ${BINDIR}${udevrulesddir} || die |
174 |
|
|
175 |
# install our udev rule |
# install our udev rule |
176 |
install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/udev/rules.d/${udevrule} || die |
install -v -m 0644 -o root -g root ${file} ${BINDIR}${udevrulesddir}/${udevrule} || die |
177 |
} |
} |
178 |
|
|
179 |
minstalludevhelper() |
minstalludevhelper() |
180 |
{ |
{ |
181 |
local udevhelper |
local udevhelper |
182 |
local file |
local file |
183 |
|
local udevdir="/usr/lib/udev" |
184 |
|
|
185 |
[[ -z "$1" ]] && die "No udev helper given" |
[[ -z "$1" ]] && die "No udev helper given" |
186 |
|
|
187 |
# if no fullpath given use file from sourcedir |
# if no fullpath given use file from sourcedir |
188 |
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
189 |
then |
then |
190 |
file="${SOURCEDIR}/${PNAME}/$1" |
file="${SOURCEDIR}/$(mpname)/$1" |
191 |
else |
else |
192 |
file="$1" |
file="$1" |
193 |
fi |
fi |
200 |
fi |
fi |
201 |
|
|
202 |
# needed directory |
# needed directory |
203 |
install -d ${BINDIR}/lib/udev || die |
install -d ${BINDIR}${udevdir} || die |
204 |
|
|
205 |
# install our udev-helper |
# install our udev-helper |
206 |
install -v -m 0755 -o root -g root ${file} ${BINDIR}/lib/udev/${udevhelper} || die |
install -v -m 0755 -o root -g root ${file} ${BINDIR}${udevdir}/${udevhelper} || die |
207 |
} |
} |
208 |
|
|
209 |
minstallhalinformation() |
minstallhalinformation() |
216 |
# if no fullpath given use file from sourcedir |
# if no fullpath given use file from sourcedir |
217 |
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
218 |
then |
then |
219 |
file="${SOURCEDIR}/${PNAME}/$1" |
file="${SOURCEDIR}/$(mpname)/$1" |
220 |
else |
else |
221 |
file="$1" |
file="$1" |
222 |
fi |
fi |
245 |
# if no fullpath given use file from sourcedir |
# if no fullpath given use file from sourcedir |
246 |
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
247 |
then |
then |
248 |
file="${SOURCEDIR}/${PNAME}/$1" |
file="${SOURCEDIR}/$(mpname)/$1" |
249 |
else |
else |
250 |
file="$1" |
file="$1" |
251 |
fi |
fi |
274 |
# if no fullpath given use file from sourcedir |
# if no fullpath given use file from sourcedir |
275 |
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
276 |
then |
then |
277 |
file="${SOURCEDIR}/${PNAME}/$1" |
file="${SOURCEDIR}/$(mpname)/$1" |
278 |
else |
else |
279 |
file="$1" |
file="$1" |
280 |
fi |
fi |
376 |
# if no fullpath given use file from sourcedir |
# if no fullpath given use file from sourcedir |
377 |
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
378 |
then |
then |
379 |
file="${SOURCEDIR}/${PNAME}/$1" |
file="${SOURCEDIR}/$(mpname)/$1" |
380 |
else |
else |
381 |
file="$1" |
file="$1" |
382 |
fi |
fi |
414 |
# if no fullpath given use file from sourcedir |
# if no fullpath given use file from sourcedir |
415 |
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
416 |
then |
then |
417 |
file="${SOURCEDIR}/${PNAME}/$1" |
file="${SOURCEDIR}/$(mpname)/$1" |
418 |
else |
else |
419 |
file="$1" |
file="$1" |
420 |
fi |
fi |
449 |
# if no fullpath given use file from sourcedir |
# if no fullpath given use file from sourcedir |
450 |
if [[ -z $(dirname $2) ]] || [[ $(dirname $2) = . ]] |
if [[ -z $(dirname $2) ]] || [[ $(dirname $2) = . ]] |
451 |
then |
then |
452 |
file="${SOURCEDIR}/${PNAME}/$2" |
file="${SOURCEDIR}/$(mpname)/$2" |
453 |
else |
else |
454 |
file="$2" |
file="$2" |
455 |
fi |
fi |
470 |
|
|
471 |
|
|
472 |
# installs logrotate configuration files |
# installs logrotate configuration files |
473 |
# minstallpam /path/to/logrotatefile {destfilename} |
# minstalllog /path/to/logrotatefile {destfilename} |
474 |
minstalllog() |
minstalllog() |
475 |
{ |
{ |
476 |
local logfile |
local logfile |
481 |
# if no fullpath given use file from sourcedir |
# if no fullpath given use file from sourcedir |
482 |
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
483 |
then |
then |
484 |
file="${SOURCEDIR}/${PNAME}/$1" |
file="${SOURCEDIR}/$(mpname)/$1" |
485 |
else |
else |
486 |
file="$1" |
file="$1" |
487 |
fi |
fi |
528 |
|
|
529 |
if [[ $1 = -s ]] |
if [[ $1 = -s ]] |
530 |
then |
then |
531 |
file="${SOURCEDIR}/${PNAME}/$2" |
file="${SOURCEDIR}/$(mpname)/$2" |
532 |
dest="$3" |
dest="$3" |
533 |
if [[ -z $3 ]] |
if [[ -z $3 ]] |
534 |
then |
then |
560 |
|
|
561 |
if [[ $1 = -s ]] |
if [[ $1 = -s ]] |
562 |
then |
then |
563 |
file="${SOURCEDIR}/${PNAME}/$2" |
file="${SOURCEDIR}/$(mpname)/$2" |
564 |
dest="$3" |
dest="$3" |
565 |
if [[ -z $3 ]] |
if [[ -z $3 ]] |
566 |
then |
then |
587 |
{ |
{ |
588 |
local file |
local file |
589 |
local dest |
local dest |
590 |
|
local verbose="-v" |
591 |
|
|
592 |
|
# check for busybox as it doesn'tz support 'ln -v' |
593 |
|
[[ $(readlink $(which ln)) = */busybox ]] && verbose="" |
594 |
|
|
595 |
[[ -z $1 ]] && die "No file given" |
[[ -z $1 ]] && die "No file given" |
596 |
|
|
597 |
if [[ $1 = -s ]] |
if [[ $1 = -s ]] |
598 |
then |
then |
599 |
file="${SOURCEDIR}/${PNAME}/$2" |
file="${SOURCEDIR}/$(mpname)/$2" |
600 |
dest="$3" |
dest="$3" |
601 |
if [[ -z $3 ]] |
if [[ -z $3 ]] |
602 |
then |
then |
620 |
# 1. - library.so.1.0.0 -> library.so.1.0 |
# 1. - library.so.1.0.0 -> library.so.1.0 |
621 |
if [ "${file%.*}" != *.so ] |
if [ "${file%.*}" != *.so ] |
622 |
then |
then |
623 |
ln -v -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*}) |
ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*}) |
624 |
fi |
fi |
625 |
# 2. - library.so.1.0.0 -> library.so.1 |
# 2. - library.so.1.0.0 -> library.so.1 |
626 |
if [ "${file%.*.*}" != *.so ] |
if [ "${file%.*.*}" != *.so ] |
627 |
then |
then |
628 |
ln -v -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*.*}) |
ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*.*}) |
629 |
fi |
fi |
630 |
} |
} |
631 |
|
|
638 |
# recursive |
# recursive |
639 |
if [[ $1 = -r ]] || [[ $1 = -R ]] |
if [[ $1 = -r ]] || [[ $1 = -R ]] |
640 |
then |
then |
641 |
opts="--recursive" |
opts="-R" |
642 |
source="$2" |
source="$2" |
643 |
dest="$3" |
dest="$3" |
644 |
fi |
fi |
646 |
# recursive |
# recursive |
647 |
if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]] |
if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]] |
648 |
then |
then |
649 |
opts="--recursive --force" |
opts="-R -f" |
650 |
|
source="$2" |
651 |
|
dest="$3" |
652 |
|
fi |
653 |
|
|
654 |
|
if [[ $1 = -a ]] |
655 |
|
then |
656 |
|
opts="-a" |
657 |
source="$2" |
source="$2" |
658 |
dest="$3" |
dest="$3" |
659 |
fi |
fi |
664 |
cp -v ${opts} ${source} ${BINDIR}/${dest} || die |
cp -v ${opts} ${source} ${BINDIR}/${dest} || die |
665 |
} |
} |
666 |
|
|
667 |
|
mdelete() |
668 |
|
{ |
669 |
|
local dest="$1" |
670 |
|
local opts |
671 |
|
|
672 |
|
# recursive |
673 |
|
if [[ $1 = -r ]] || [[ $1 = -R ]] |
674 |
|
then |
675 |
|
opts="-r" |
676 |
|
dest="$2" |
677 |
|
fi |
678 |
|
|
679 |
|
# recursive |
680 |
|
if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]] |
681 |
|
then |
682 |
|
opts="-r -f" |
683 |
|
dest="$2" |
684 |
|
fi |
685 |
|
|
686 |
|
[[ -z ${dest} ]] && die "No dest given." |
687 |
|
[[ ! -e ${BINDIR}/${dest} ]] && die "${BINDIR}/${dest} does not exist." |
688 |
|
|
689 |
|
rm -v ${opts} ${BINDIR}/${dest} || die |
690 |
|
} |
691 |
|
|
692 |
mmove() |
mmove() |
693 |
{ |
{ |
694 |
local source="$1" |
local source="$1" |
698 |
# force |
# force |
699 |
if [[ $1 = -f ]] |
if [[ $1 = -f ]] |
700 |
then |
then |
701 |
opts="--recursive" |
opts="-f" |
702 |
source="$2" |
source="$2" |
703 |
dest="$3" |
dest="$3" |
704 |
fi |
fi |
744 |
# recursive |
# recursive |
745 |
if [[ $1 = -r ]] || [[ $1 = -R ]] |
if [[ $1 = -r ]] || [[ $1 = -R ]] |
746 |
then |
then |
747 |
local recursive="--recursive" |
local recursive="-R" |
748 |
local owner="$2" |
local owner="$2" |
749 |
local path="$3" |
local path="$3" |
750 |
fi |
fi |
764 |
# recursive |
# recursive |
765 |
if [[ $1 = -r ]] || [[ $1 = -R ]] |
if [[ $1 = -r ]] || [[ $1 = -R ]] |
766 |
then |
then |
767 |
local recursive="--recursive" |
local recursive="-R" |
768 |
local posix="$2" |
local posix="$2" |
769 |
local path="$3" |
local path="$3" |
770 |
fi |
fi |
779 |
{ |
{ |
780 |
local symlink="$1" |
local symlink="$1" |
781 |
local pathto="$2" |
local pathto="$2" |
782 |
|
local verbose="-v" |
783 |
|
|
784 |
|
# check for busybox as it doesn'tz support 'ln -v' |
785 |
|
[[ $(readlink $(which ln)) = */busybox ]] && verbose="" |
786 |
|
|
787 |
[[ -z ${symlink} ]] && die "No symlink given." |
[[ -z ${symlink} ]] && die "No symlink given." |
788 |
[[ -z ${pathto} ]] && die "No path given." |
[[ -z ${pathto} ]] && die "No path given." |
789 |
|
|
790 |
ln -v -snf ${symlink} ${BINDIR}/${pathto} || die |
ln ${verbose} -snf ${symlink} ${BINDIR}/${pathto} || die |
791 |
|
} |
792 |
|
|
793 |
|
# installs systemd units |
794 |
|
# minstallunit /path/to/unit-file {destfilename} |
795 |
|
minstallunit() |
796 |
|
{ |
797 |
|
local unit |
798 |
|
local file |
799 |
|
local systemdunitdir="/usr/lib/systemd/system" |
800 |
|
|
801 |
|
[[ -z "$1" ]] && die "No unit given" |
802 |
|
|
803 |
|
# if no fullpath given use file from sourcedir |
804 |
|
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
805 |
|
then |
806 |
|
file="${SOURCEDIR}/$(mpname)/$1" |
807 |
|
else |
808 |
|
file="$1" |
809 |
|
fi |
810 |
|
|
811 |
|
if [[ -n "$2" ]] |
812 |
|
then |
813 |
|
unit="$2" |
814 |
|
else |
815 |
|
unit="$(basename ${file})" |
816 |
|
fi |
817 |
|
|
818 |
|
# needed directory |
819 |
|
install -d ${BINDIR}${prefix}${systemdunitdir} || die |
820 |
|
|
821 |
|
# install our initscript |
822 |
|
install -v -m 0644 -o root -g root ${file} ${BINDIR}${prefix}${systemdunitdir}/${unit} || die |
823 |
|
} |
824 |
|
|
825 |
|
# installs systemd tmp configs to /etc/tmpfiles.d |
826 |
|
# minstalltmp /path/to/tmpdfile {destfilename} |
827 |
|
minstalltmp() |
828 |
|
{ |
829 |
|
local tmpdfile |
830 |
|
local file |
831 |
|
|
832 |
|
[[ -z "$1" ]] && die "No tmpd file given" |
833 |
|
|
834 |
|
# if no fullpath given use file from sourcedir |
835 |
|
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
836 |
|
then |
837 |
|
file="${SOURCEDIR}/$(mpname)/$1" |
838 |
|
else |
839 |
|
file="$1" |
840 |
|
fi |
841 |
|
|
842 |
|
if [[ -n "$2" ]] |
843 |
|
then |
844 |
|
tmpdfile="$2" |
845 |
|
else |
846 |
|
tmpdfile="$(basename ${file})" |
847 |
|
fi |
848 |
|
|
849 |
|
# needed directory |
850 |
|
install -d ${BINDIR}/etc/tmpfiles.d || die |
851 |
|
|
852 |
|
# install our tmpdfile |
853 |
|
install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/tmpfiles.d/${tmpdfile} || die |
854 |
|
} |
855 |
|
|
856 |
|
mclearconfig() |
857 |
|
{ |
858 |
|
local confdir |
859 |
|
local prefix="${BINDIR}" |
860 |
|
[[ -z ${MCONFIG} ]] && die "No \$MCONFIG given!" |
861 |
|
|
862 |
|
# no bindir prefix if requested |
863 |
|
case $1 in |
864 |
|
-b|--no-bindir) prefix="";; |
865 |
|
esac |
866 |
|
|
867 |
|
confdir="$(dirname ${MCONFIG})" |
868 |
|
if [[ ! -d ${prefix}/${confdir} ]] |
869 |
|
then |
870 |
|
install -d ${prefix}/${confdir} || die |
871 |
|
fi |
872 |
|
: > ${prefix}/${MCONFIG} |
873 |
|
} |
874 |
|
|
875 |
|
maddconfig() |
876 |
|
{ |
877 |
|
local argv="$1" |
878 |
|
local confdir |
879 |
|
local prefix="${BINDIR}" |
880 |
|
|
881 |
|
[[ -z ${MCONFIG} ]] && die "No \$MCONFIG given!" |
882 |
|
|
883 |
|
# no bindir prefix if requested |
884 |
|
case $1 in |
885 |
|
-b|--no-bindir) prefix=""; argv="$2" ;; |
886 |
|
esac |
887 |
|
|
888 |
|
[[ -z ${argv} ]] && die "No argument given!" |
889 |
|
|
890 |
|
confdir="$(dirname ${MCONFIG})" |
891 |
|
if [[ ! -d ${prefix}/${confdir} ]] |
892 |
|
then |
893 |
|
install -d ${prefix}/${confdir} || die |
894 |
|
fi |
895 |
|
echo "${argv}" >> ${prefix}/${MCONFIG} || die |
896 |
} |
} |