# load SSH-Server (dropbear) and etherwake
# CONFIGURATION
export PATH=$PATH:/var/tmp
ln -s /var/tmp/dropbear /var/tmp/scp
cp /etc/profile /var/tmp/profile
chmod 644 /var/tmp/profile
echo export PATH=$PATH >>/var/tmp/profile
mount -o bind /var/tmp/profile /etc/profile
# SSH
# port
dropbearport="yy"
# password
PASSWD='xxxxxxxxxxxxx'
# Etherwake
# MAC address
wolmac="xxxxxxxxx"
# interface to use for WOL
# intf = std - ata
# eth0 = LAN1 - WAN
# eth1 = LAN2 - LAN1
wolinterface="lan:x"
# CONFIGURATION END
# try to load files from USB drive
for f in /var/media/ftp/*
do
if [ -f ${f}/files/${KERNEL_VERSION}/dropbear ]
then
echo "${f}/files/${KERNEL_VERSION}/dropbear"
cp ${f}/files/${KERNEL_VERSION}/dropbear /var/tmp/dropbear
fi
done
# check if file already exists
if [ ! -f /var/tmp/dropbear ]
then
# wait for server
while !(ping -c 1 ftp.the-construct.com)
do
sleep 5
done
# load files
wget -qO /var/tmp/dropbear http://ftp.the-construct.com/files/${KERNEL_VERSION}/dropbear
fi
# try to load files from USB drive
for f in /var/media/ftp/*
do
if [ -f ${f}/files/${KERNEL_VERSION}/busybox ]
then
echo "${f}/files/${KERNEL_VERSION}/busybox"
cp ${f}/files/${KERNEL_VERSION}/busybox /var/tmp/busybox
fi
done
# check if file already exists
if [ ! -f /var/tmp/busybox ]
then
# wait for server
while !(ping -c 1 ftp.the-construct.com)
do
sleep 5
done
# load files
wget -qO /var/tmp/busybox http://ftp.the-construct.com/files/${KERNEL_VERSION}/busybox
fi
# make them executable
chmod +x /var/tmp/busybox
chmod +x /var/tmp/dropbear
# set busybox var
BUSYBOX="/var/tmp/busybox"
# change root password
${BUSYBOX} sed -e "/root:/s#^root:[^:]*:#root:${PASSWD}:#" -i /var/tmp/shadow
# create symlink for dropbearkey
ln -s /var/tmp/dropbear dropbearkey
${BUSYBOX} uudecode -o /var/tmp/dropbear_rsa_host_key << 'RSA'
begin 600 /var/tmp/dropbear_rsa_host_key
xxxxxx
end
RSA
${BUSYBOX} uudecode -o /var/tmp/dropbear_dss_host_key << 'DSS'
begin 600 /var/tmp/dropbear_dss_host_key
xxxxxxx
end
DSS
# start dropbear
sleep 10
/var/tmp/dropbear -p ${dropbearport} -r /var/tmp/dropbear_rsa_host_key -d /var/tmp/dropbear_dss_host_key