# Hook addon for common utils # copy internal tcos conf cp $TCOS_DIR/tcos-run-functions.sh $DESTDIR/conf/tcos-run-functions cp $CONFDIR/tcos.conf $DESTDIR/conf/ for tpl in $(tcos_get_templates); do _verbose "(00main) cat $tpl >> $DESTDIR/conf/tcos.conf" cat $tpl >> $DESTDIR/conf/tcos.conf done # load forced settings for derivatives if [ -d $CONFDIR/conf.d/ ]; then for file in $CONFDIR/conf.d/tcos*conf; do [ -e $file ] && cat $file >> $DESTDIR/conf/tcos.conf done fi # clean tcos.conf file (delete empty lines and comments) grep -v "^#" $DESTDIR/conf/tcos.conf | grep "=" | grep -v "^TEMPLATE" > $DESTDIR/conf/tcos.conf.tmp mv $DESTDIR/conf/tcos.conf.tmp $DESTDIR/conf/tcos.conf # make some dirs [ -d $DESTDIR/dev ] || mkdir -m 0755 $DESTDIR/dev [ -d $DESTDIR/root ] || mkdir --mode=0700 $DESTDIR/root [ -d $DESTDIR/ram ] || mkdir $DESTDIR/ram [ -d $DESTDIR/nfs ] || mkdir $DESTDIR/nfs mkdir -p $DESTDIR/usr/bin mkdir -p $DESTDIR/usr/sbin mkdir -p $DESTDIR/lib/lsb/ cp /lib/lsb/init-functions ${DESTDIR}/lib/lsb/ cpifexists /etc/debian_version /etc/ cpifexists $TCOS_DIR/tcos-modules.conf /conf/ # seq script cpifexists ${TCOS_BINS}/seq /bin # get_filesystem cpifexists ${TCOS_BINS}/get_filesystem /bin # limits cpifexists ${TCOS_BINS}/set-limits /bin # exec and daemonize cpifexists ${TCOS_BINS}/daemonize.sh /sbin # tcos-pam-usb.sh (tcosxmlrpc helper) cpifexists ${TCOS_BINS}/tcos-pam-usb.sh /sbin rm -f $DESTDIR/sbin/start-stop-daemon # in tcos-buildchroot we save this exe file in start-stop-daemon.original if [ -e /sbin/start-stop-daemon.original ]; then copy_exec /sbin/start-stop-daemon.original /sbin/ rm -f $DESTDIR/sbin/start-stop-daemon.original cp -a /sbin/start-stop-daemon.original $DESTDIR/sbin/start-stop-daemon if [ "$(file ${DESTDIR}/sbin/start-stop-daemon | grep -c ELF)" = "0" ]; then _echo " * WARNING:" _echo " /sbin/start-stop-daemon is not a ELF (binary) file" _echo " Some apps will not work." fi elif [ -e /sbin/start-stop-daemon.REAL ]; then copy_exec /sbin/start-stop-daemon.REAL /sbin/ rm -f $DESTDIR/sbin/start-stop-daemon.REAL rm -f $DESTDIR/sbin/start-stop-daemon cp -a /sbin/start-stop-daemon.REAL $DESTDIR/sbin/start-stop-daemon if [ "$(file ${DESTDIR}/sbin/start-stop-daemon | grep -c ELF)" = "0" ]; then _echo " * WARNING:" _echo " /sbin/start-stop-daemon is not a ELF (binary) file" _echo " Some apps will not work." fi else copy_exec /sbin/start-stop-daemon /sbin/ rm -f $DESTDIR/sbin/start-stop-daemon cp -a /sbin/start-stop-daemon $DESTDIR/sbin/start-stop-daemon fi # exec and daemonize cpifexists ${TCOS_BINS}/clear-logs /bin if [ "${TCOS_INCLUDE_INIT}" != "1" ]; then # only include ldconfig in no NFS image # ubuntu hack for ldconfig if [ -e /sbin/ldconfig.real ]; then cpifexists /sbin/ldconfig.real /usr/sbin/ # rename rm -f $DESTDIR/usr/sbin/ldconfig.real cp -a /sbin/ldconfig.real $DESTDIR/usr/sbin/ldconfig else cpifexists /sbin/ldconfig /usr/sbin/ fi fi [ -f /etc/ld.so.conf ] && cpifexists /etc/ld.so.conf /etc/ [ ! -f /etc/ld.so.conf ] && echo "/usr/lib" >> $DESTDIR/etc/ld.so.conf cpifexists /sbin/depmod /sbin/ cpifexists /etc/localtime /etc/ [ -f /etc/adjtime ] && cpifexists /etc/adjtime /etc/ cpifexists /etc/securetty /etc cpifexists /etc/services /etc/ # create (if not exists) empty modules file touch $DESTDIR/etc/modules mkdir -p $DESTDIR/usr/lib cpifexists /lib/libresolv.so.2 /lib/ cpifexists /usr/lib/libgssapi_krb5.so.2 /usr/lib/ # need to copy this libs to support usernames with busybox cpifexists /lib/libnss_compat.so.2 /lib/ cpifexists /lib/libnss_files.so.2 /lib/ cpifexists /lib/libnss_nis.so.2 /lib/ cpifexists /lib/libnss_dns.so.2 /lib/ [ -e /usr/lib/libnss_db.so.2 ] && cpifexists /usr/lib/libnss_db.so.2 /usr/lib/ # new lib (needed for DNS calls) [ -e /lib/libnss_mdns4_minimal.so.2 ] && cpifexists /lib/libnss_mdns4_minimal.so.2 /lib/ # needed for NFS [ -x /sbin/portmap ] && cpifexists /sbin/portmap /sbin # create some dirs mkdir -p $DESTDIR/var/log touch $DESTDIR/var/log/lastlog mkdir -p ${DESTDIR}/var/run # hack run_scripts... TCOS use numbered cat << EOF >> $DESTDIR/scripts/functions # TCOS hacked ;) run_scripts() { initdir=\${1} [ ! -d \${1} ] && return for sc in \$(ls -t1 \${1}); do \${1}/\${sc} done } EOF cat << EOF > $DESTDIR/sbin/down-listener #!/bin/sh . /conf/tcos-run-functions MAX=15 COUNT=0 sleep 1 [ ! -e /tmp/downloading ] && exit 0 while [ -e /tmp/downloading ] && [ \$COUNT -lt \$MAX ]; do update_progress 1 COUNT=\$((\$COUNT+1)) sleep 1 done EOF chmod +x $DESTDIR/sbin/down-listener