Annotation of elwix/config/rc.subr, revision 1.6.2.2
1.1 misho 1: #
2: # ELWIX project build helper subroutines
3: #
4: # (C) AITNET ltd - Sofia/Bulgaria <office@aitnet.org>
5: # by Michael Pounov <misho@elwix.org>
6: #
1.6.2.2 ! misho 7: # $Id: rc.subr,v 1.6.2.1 2013/07/31 15:53:43 misho Exp $
1.1 misho 8: #
9:
10: ### Dont edit this file !!!
11:
12: CheckVer()
13: {
14: [ -z "$1" -o ! -r "$1" ] && return 1
15:
16: cat $1 | awk '($1 == "ELWIX") { split($3, arr, ":"); printf("%s", arr[2]); }'
17: return 0
18: }
19:
20: SnitVer()
21: {
22: install -d ${TOPDIR}
23:
24: V=$(CheckVer $1)
25:
26: if [ $? -ne 0 ]; then
27: # file not found
28: return 1
29: elif [ X"$V" != X"${VERSION}" ]; then
30: # different ELWIX version
31: return 2
32: fi
33:
34: # already present file with same version
35: return 0
36: }
37:
1.6.2.2 ! misho 38: Create_etc_motd()
! 39: {
! 40: ELWIX_VER="ELWIX-${VERSION}_$2_${TARGET_ARCH}";
! 41: ELWIX_HDR_MOTD="${ELWIX_VER} :: Build date ${BUILD_DATE}";
! 42:
! 43: awk -v fo="${1:-motd}" 'BEGIN { print "'"${ELWIX_HDR_MOTD}"'" > fo; } { print $0 >> fo; }' \
! 44: ${CFGDIR}/elwix_signature.txt;
! 45: }
! 46:
1.6.2.1 misho 47: # $1 = fs/elwix
48: # $2 = config/etc/default
49: MakeFS_var()
50: {
51: cd $1
52:
53: install -d altroot;
54: install -d altroot/var;
55: install -d altroot/var/account;
56: install -d altroot/var/at;
57: install -d altroot/var/at/jobs;
58: install -d altroot/var/at/spool;
59: install -d -g 63 -m 0770 altroot/var/authpf;
60: install -d -m 0750 altroot/var/cron;
61: install -d -m 0700 altroot/var/cron/tabs;
62: install -d altroot/var/db;
63: install -d -m 0555 altroot/var/empty;
64: install -d altroot/var/log;
65: install -d -o 101 -g 101 altroot/var/log/quagga;
66: install -d -o 883 -g 883 altroot/var/mqtt;
67: install -d altroot/var/named;
68: install -d altroot/var/run;
69: install -d altroot/var/sys;
70: install -d -o 53 -g 53 altroot/var/run/named;
71: install -d -o 101 -g 101 altroot/var/run/quagga;
72: install -d altroot/var/spool;
73: install -d -o 66 -g 68 -m 0775 altroot/var/spool/lock;
74: install -d -g 1 altroot/var/spool/lpd;
75: install -d -g 1 altroot/var/spool/output;
76: install -d -g 1 altroot/var/spool/output/lpd;
77:
78: ln -fs /tmp altroot/var/tmp;
79:
80: touch altroot/var/run/utmp
81:
82: touch altroot/var/account/acct
83:
84: touch altroot/var/log/elwix
85: touch altroot/var/log/lastlog
86: touch altroot/var/log/wifi.log
87: touch altroot/var/log/utx.log
88:
89: touch altroot/var/log/auth.log
90: touch altroot/var/log/cron
91: touch altroot/var/log/console.log
92: touch altroot/var/log/debug.log
93: touch altroot/var/log/init.log
94: touch altroot/var/log/lpd-errs
95: touch altroot/var/log/maillog
96: touch altroot/var/log/messages
97: touch altroot/var/log/security
98: touch altroot/var/log/xferlog
99: touch altroot/var/log/ppp.log
100: chgrp 69 altroot/var/log/ppp.log
101:
102: InstallDir ${WORLD}/var/named $1/altroot/var/named
103: InstallList ${ELWIX_BSDSRC} ${BSDSRC} $1/altroot/var/named
104: install -v $2/resolv.safe altroot/var/run/resolv.conf
105:
106: chown -hR root:wheel .
107: cd -
108: }
109:
1.6.2.2 ! misho 110: # $1 = fs/elwix
! 111: # $2 = config/etc/default
! 112: # $3 = name
! 113: MakeFS_etc()
! 114: {
! 115: InstallDir $2 $1/etc
! 116:
! 117: chown -R root:wheel $1/etc;
! 118:
! 119: chmod 0600 $1/etc/opieaccess;
! 120: chmod 0600 $1/etc/opiekeys;
! 121:
! 122: chmod 0600 $1/etc/master.passwd;
! 123: chmod 0600 $1/etc/spwd.db;
! 124: chmod 0600 $1/etc/ssh/ssh_host_dsa_key;
! 125: chmod 0600 $1/etc/ssh/ssh_host_key;
! 126: chmod 0600 $1/etc/ssh/ssh_host_rsa_key;
! 127: chmod 0600 $1/etc/ssh/ssh_host_ecdsa_key;
! 128:
! 129: chmod 0440 $1/etc/sudoers;
! 130:
! 131: chgrp 80 $1/etc/config.xml;
! 132: chmod 0660 $1/etc/config.xml;
! 133:
! 134: mkdir -p $1/etc/mqtt;
! 135: chgrp -R 883 $1/etc/mqtt;
! 136: chown -R 883 $1/etc/mqtt;
! 137:
! 138: ln -sf /etc/rc.s $1/etc/rc.S
! 139:
! 140: ln -sf /usr/share/zoneinfo/${TIMEZONE} $1/etc/localtime;
! 141: ln -sf /usr/share/misc/termcap $1/etc/termcap;
! 142:
! 143: ln -sf /var/named/etc/namedb $1/etc/namedb;
! 144: ln -sf /var/run/resolv.conf $1/etc/resolv.conf;
! 145:
! 146: ln -sf /elwix/pkg/etc/mk.conf $1/etc/mk.conf;
! 147:
! 148: echo ${TARGET_ARCH} >$1/etc/platform;
! 149:
! 150: Create_etc_motd $1/etc/motd $3;
! 151:
! 152: CleanCVS $1
! 153: CleanCVS $1/etc
! 154: }
! 155:
1.1 misho 156: # $1 = ELWIX install list config
157: # $2 = From World dir
158: # $3 = To Dest dir
159: InstallList()
160: {
1.4 misho 161: local TMPFILE=$(mktemp -q /tmp/instlist.XXXXXX)
162: if [ $? -ne 0 ]; then
163: echo "Error:: Can't create temp file, exiting..."
164: exit 1
165: fi
166:
167: sed -nE -e 's/^ *([^ #]+) */\1/p' < $1 | tr ':' '\n' >$TMPFILE
168: cd $2
169: for i in $(cat $TMPFILE); do
170: if [ -x $i ]; then
171: echo "Strip '$i'"
172: strip -s $i
173: fi
174: done
175: cd -
176: tar -C $2 -cvf - -T $TMPFILE | tar -C $3 -x -f -
177: rm -f $TMPFILE
1.1 misho 178: }
179:
180: # $1 = From dir
181: # $2 = To dir
1.2 misho 182: InstallDir()
1.1 misho 183: {
184: cd $1
185: pax -rw -pe -X . $2
186: cd -
187: }
188:
189: # $* = Program arguments for install tool
190: InstallProg()
191: {
192: install -c $*
193: }
1.2 misho 194:
195: # $1 = file_pattern
1.3 misho 196: # $2 = From dir
197: # $3 = To dir
1.2 misho 198: InstallFiles()
199: {
1.3 misho 200: if [ -d "$2" ]; then
201: cd $2
202: find . -type f -name "$1" |
203: tar -cvf - -T - | tar -C $3 -xf -
204: cd -
205: fi
206: }
207:
208: # $1 = Directory for clean
209: CleanCVS()
210: {
211: find $1 -type d -name CVS -exec rm -rf {} \; >/dev/null 2>&1
212: find $1 -type f -name .#\* -exec rm -f {} \; >/dev/null 2>&1
1.2 misho 213: }
1.3 misho 214:
1.4 misho 215: # $1 = file_pattern
216: # $2 = From dir
217: StripFiles()
218: {
219: if [ -d "$2" ]; then
220: local TMPFILE=$(mktemp -q /tmp/instlist.XXXXXX)
221: if [ $? -ne 0 ]; then
222: echo "Error:: Can't create temp file, exiting..."
223: exit 1
224: fi
225:
226: cd $2
227: find . -type f -name "$1" >$TMPFILE
228: for i in $(cat $TMPFILE); do
229: if [ -x $i ]; then
230: echo "Strip '$i'"
231: strip -s $i
232: fi
233: done
234: cd -
235: rm -f $TMPFILE
236: fi
237: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>