#this is to restore my Ben.
#echo "Battery info:"
#cat /sys/class/power_supply/battery/uevent
uci set system.@system[0].hostname=ben
uci set system.@system[0].timezone=MSK-4
uci set network.lan.dns=213.234.192.8
uci set network.lan.gateway=192.168.254.100
uci commit
#/etc/init.d/network restart
echo "MSK-4" > /etc/TZ

#sed -i 's/tty1::askfirst:\/bin\/ash\ --login/tty1::respawn:\/usr\/bin\/fbterm\ -s\ 10/g' /etc/inittab
#sed -i 's/tty1::askfirst:\/bin\/ash\ --login/tty1::respawn:\/bin\/ash\ --login/g' /etc/inittab
#sed -i -e 's/tty3/#tty3/g' -e 's/tty4/#tty4/g' -e 's/ttyS0/#ttyS0/g' -e 's/tts\/0/#tts\/0/g' /etc/inittab
#sed -i 's/\/bin\/ldd/\/usr\/bin\/ldd/' /etc/profile
#sed -i -e 's/\[ -x \/sbin\/klogd ] && klogd ${klogconloglevel:+-c $klogconloglevel}/#&/g' -e 's/syslogd -C${log_size} ${log_ip:+-L -R ${log_ip}:${log_port}}/#&\n\t\t\ttrue/g' /etc/init.d/boot
mkdir /data
mkdir /card
#ubiattach /dev/ubi_ctrl -m 3
#mount -t ubifs ubi1:data /data/
#echo "export SDL_NOMOUSE=1" >> /etc/profile
#echo "export SDL_VIDEODRIVER=fbcon" >> /etc/profile
#echo "export TERM=linux" >> /etc/profile
echo "alias sdcveg='sdcv --data-dir /data/dict_ege/ --utf8-output --utf8-input'" >> /etc/profile
echo "alias sdcvrg='sdcv --data-dir /data/dict_rgr/ --utf8-output --utf8-input'" >> /etc/profile
echo "alias sdcvre='sdcv --data-dir /data/dict_rer/ --utf8-output --utf8-input'" >> /etc/profile
#echo "export HISTFILE=$HOME/.ash_history" >> /etc/profile
#echo "export LC_ALL=ru_RU.UTF-8" >> /etc/profile
#echo "fbterm -s 10" >> /etc/profile
echo "setterm -bfreq 0;clear" >> /etc/profile
echo "ubiattach /dev/ubi_ctrl -m 3" > /usr/bin/mount.sh
echo "mount -t ubifs ubi1:data /data/" >> /usr/bin/mount.sh
chmod +x /usr/bin/mount.sh
#echo "no-deinit-check" > /etc/directfbrc
echo "#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org

START=99
boot() {
        /sbin/swapon /dev/mmcblk0p2
        /usr/bin/mount.sh
        /bin/mount /dev/mmcblk0p1 /card
}
" > /etc/init.d/start
echo "#!/bin/sh

source /etc/profile

loadkeys /usr/share/ben-cyrillic/ben_ru_uni.map 2>&1 > /dev/null
setfont /usr/share/kbd/consolefonts/ter-v12n.psf 2>&1 > /dev/null

trap \"\" hup

clear
exec /usr/bin/gmenu2x.bin
" > /usr/bin/gmenu2x
chmod +x /etc/init.d/start
/etc/init.d/start enable
#cd /etc/rc.d; ln -s ../init.d/start S59start
#echo "now reboot and run commands at the end of this file."
#return 0
#ntpdate pool.ntp.org #(synchronize date/time with NTP server)
#hwclock -w #(set RTC clock)
#hwclock -u #(set to UTC)
rm -rf /root/Maps
ln -s /data/Maps /root/Maps
rm -rf /root/Settings
ln -s /data/Settings /root/Settings
rm -rf /root/.supertux
ln -s /data/.supertux /root/.supertux
rm -rf /root/.abook
ln -s /data/.abook /root/.abook
rm -rf /root/.config
ln -s /data/.config /root/.config

mkdir -p /usr/share/stardict/dic
#ln -s /data/dict_ege /usr/share/stardict/dic/dict_ege
ln -s /data/dict_rer /usr/share/stardict/dic/dict_rer
#ln -s /data/dict_rgr /usr/share/stardict/dic/dict_rgr
echo "---
#path_to_data: ./data
path_to_data: /usr/share/nightsky
location:
  latitude:  55.753
  longitude: 37.6199
" > /root/.nightsky.yml
#mkdir /usr/lib/tcl8.5
#echo "source /root/.tclshrc" > /usr/lib/tcl8.5/init.tcl
#echo "set encoding=utf-8" > /root/.vimrc
#TAKE THIS THING FROM GIT!
#echo "# 8Bits supports.
#set meta-flag on
#set convert-meta off
#set input-meta on
#set output-meta on
#" > /etc/inputrc

#mkdir /root/.mplayer
#echo "sub-fuzziness=1
#utf8=1
#volume=10
#vo=sdl
#ac=mad
#" >> /root/.mplayer/config
/etc/init.d/keymouse disable
/etc/init.d/setserial disable
/etc/init.d/usb disable
#actually, this one needs to be disabled in package...
/etc/init.d/ben-cyrillic disable
/etc/init.d/cron disable
/etc/init.d/watchdog disable
/etc/init.d/gdk-pixbuf-query-loaders disable
/etc/init.d/pango-querymodules disable

/etc/init.d/fstab disable
/etc/init.d/openvpn disable
/etc/init.d/done disable

#TODO: check what else to disable
echo "192.168.0.2 bas" >> /etc/hosts
#consoleblank=30:
#fw_setenv bootargs=mem=32M console=tty0 console=ttyS0,57600n8 ubi.mtd=2 rootfstype=ubifs root=ubi0:rootfs rw rootwait consoleblank=30
echo "run this on your host: ssh ben 'cat >>/etc/dropbear/authorized_keys' <~/.ssh/id_rsa.pub"
echo 'run this on your host: ssh ben "date -s \"$(date -u +"%F %T")\" && /sbin/hwclock -w"'
#echo "now check shit and reboot"
