Fritz: debug.cfg

Aus Dario's Home
Wechseln zu: Navigation, Suche
 ###
 ### Darios Fritzbox Config
 ###
 
 ###
 ### cp_from_usb $1 $2 $3
 ###    $1 = sourcefile
 ###    $2 = destinationdir
 ###    $3 = rights
 ### copies file from USB Stick (/fritzbox)) to destination dir and set rights
 ###
 cp_from_usb()
 {
   thisfile=$1
   targetdir=$2
   rights=$3
   if [ -f $sourcedir/$thisfile ]
   then
     echo "DEBUG.CFG: cp $sourcedir/$thisfile to $targetdir/$thisfile"
     cp $sourcedir/$thisfile $targetdir/$thisfile
     echo "DEBUG.CFG: chmod $rights $targetdir/$thisfile"
     chmod $rights $targetdir/$thisfile
   fi
 }
 
 
 ###
 ### start telnet deamon with password of web gui
 ###
 
 echo "DEBUG.CFG: start telnet deamon"
 /usr/sbin/telnetd -l /sbin/ar7login
 
 
 ###
 ### set hostname to fritz.box
 ###
 
 echo "DEBUG.CFG: set hostname to fritz.box"
 hostname fritz.box
 
 
 # wait for USB to be mounted
 echo "DEBUG.CFG: wait 30s ..."
 sleep 10
 echo "DEBUG.CFG: wait 20s ..."
 sleep 10
 echo "DEBUG.CFG: wait 10s ..."
 sleep 5
 echo "DEBUG.CFG: wait 5s ..."
 sleep 2
 echo "DEBUG.CFG: wait 3s ..."
 sleep 1
 echo "DEBUG.CFG: wait 2s ..."
 sleep 1
 echo "DEBUG.CFG: wait 1s ..."
 sleep 1
 
 
 ###
 ### start ssh deamon
 ###
 echo "DEBUG.CFG: ************************************"
 echo "DEBUG.CFG: *** starting dropbear SSH deamon ***"
 echo "DEBUG.CFG: ************************************"
 
 cd /var/tmp
 mkdir /var/tmp/root/
 mkdir /var/tmp/root/.ssh
 
 # password 
 # Set password is to an unknown value,  
 # thus only login with keyfile is possible 
 PASSWD='$1$rUr3ypnu$s8xnBdUV9/_somevalue_.'

 # load files from usb stick
 echo "DEBUG.CFG: loading ssh-binaries from usb stick"
 for f in /var/media/ftp/*
 do
   sourcedir=${f}/fritzbox
   # dropbear
   cp_from_usb dropbear /var/tmp +x
   # busybox
   cp_from_usb busybox /var/tmp +x
   # dropbear_dss_host_key
   cp_from_usb dropbear_dss_host_key /var/tmp 700
   # dropbear_rsa_host_key
   cp_from_usb dropbear_rsa_host_key /var/tmp 700
   # /var/tmp/root/.ssh/authorized_keys
   cp_from_usb authorized_keys /var/tmp/root/.ssh 700
   # calllog
   # the calllog script sends an email at every incoming call 
   cp_from_usb calllog /var +x
 done
 
 # set busybox var
 echo "DEBUG.CFG: set busybox var"
 BUSYBOX="/var/tmp/busybox"
 
 # change root password
 echo "DEBUG.CFG: change ssh root password"
 ${BUSYBOX} sed -e "/root:/s#^root:[^:]*:#root:${PASSWD}:#" -i /var/tmp/shadow
 
 # set $HOME for root to /var/tmp/root/
 echo "DEBUG.CFG: set HOME for root to /var/tmp/root"
 echo "root:x:0:0:root:/var/tmp/root/:/bin/sh" > /var/tmp/passwd
 
 # set set path to SCP root
 echo "DEBUG.CFG: set path to SCP"
 echo "export PATH=$PATH:/var/tmp " > /var/tmp/root/.profile
 
 # create symlink for /var/tmp/dropbearkey and /var/tmp/scp
 echo "DEBUG.CFG: create symlink for dropbearkey and scp"
 ln -s /var/tmp/dropbear dropbearkey
 ln -s /var/tmp/dropbear scp
 
 # start dropbear
 echo "DEBUG.CFG: wait 5s ..."
 sleep 5
 echo "DEBUG.CFG: start ssh deamon on port 22"
 /var/tmp/dropbear -p 22 -r /var/tmp/dropbear_rsa_host_key -d /var/tmp/dropbear_dss_host_key
 
 
 ###
 ### delete warnings for non authorized firmware :-)
 ###
 echo "DEBUG.CFG: ******************************************************"
 echo "DEBUG.CFG: *** deleting warnings for non authorized firmware  ***"
 echo "DEBUG.CFG: ******************************************************"
 
 dst=/var/tmp/signed_firmware
 src=/usr/www/html/html/de/home
 mkdir -pm 777 $dst
 for file in home.js konfig.js; do
   if [ -f $src/$file ]; then
     sed -e 's,.*var signed =.*,var signed = "1",' $src/$file > $dst/$file
     mount -o bind $dst/$file $src/$file
   fi
 done
 
 ### end of debug.cfg