Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- ### BEGIN INIT INFO
- # Provides: codesyscontrol
- # Required-Start: hostname $local_fs
- # Required-Stop:
- # Should-Start:
- # Default-Start: 2 3 4 5
- # Default-Stop:
- # Short-Description: Prepares and starts codesyscrontol
- # Description: Prepares and starts codesyscrontol
- ### END INIT INFO
- PATH=/sbin:/usr/sbin:/bin:/usr/bin
- . /lib/init/vars.sh
- make_mknod () {
- #create node if not already there
- if [ ! -c /dev/char_dev ]; then
- echo "created node"
- /bin/mknod /dev/char_dev c 100 0
- fi
- }
- do_start () {
- make_mknod
- killall codesyscontrol.bin > /dev/null;
- export PlcConfigFile=/etc/CODESYSControl.cfg
- echo bcm2708_i2c.0 > /sys/bus/platform/drivers/bcm2708_i2c/unbind
- echo 400000 > /sys/module/i2c_bcm2708/parameters/baudrate
- echo bcm2708_i2c.0 > /sys/bus/platform/drivers/bcm2708_i2c/bind
- # 1 wire
- modprobe w1-gpio pullup=1
- modprobe w1-therm
- cd /root/
- /usr/bin/codesyscontrol.bin > /tmp/codesyscontrol.log 2>&1 &
- cd -
- sleep 1 && pgrep codesyscontrol > /dev/null && echo "codesyscontrol started" || echo "ERROR: codesyscontrol not started!";
- }
- do_backuplicenses () {
- # restore und backup ordner...
- #
- # backup immer
- # restore wenn "restore" ordner nicht leer, und tar...
- #
- echo "Backup licenses"
- ARCHIVE=/root/backup/3SLicenseInfo.tar
- ARCHIVE_INFO=/root/cmact_licenses/info.lic
- date > $ARCHIVE_INFO
- uname -a >> $ARCHIVE_INFO
- cat /proc/cpuinfo >> $ARCHIVE_INFO
- ifconfig -a >> $ARCHIVE_INFO
- ls -la /root/cmact_licenses/ >> $ARCHIVE_INFO
- tar cf $ARCHIVE /root/cmact_licenses /root/3SLicense.wbb > /dev/null
- }
- do_restorelicenses () {
- ARCHIVE=/root/restore/3SLicenseInfo.tar
- NEWARCHIVE=/tmp/3SLicenseInfo.tar
- if [ -f $ARCHIVE ]; then
- mv $ARCHIVE /tmp/
- tar -xvf $NEWARCHIVE -C /
- echo "Restored licenses"
- fi
- }
- do_stop () {
- /usr/bin/killall -2 codesyscontrol.bin
- }
- case "$1" in
- start|"")
- do_restorelicenses
- do_backuplicenses
- do_start
- ;;
- restart|reload|force-reload|status)
- echo "Error: argument '$1' not supported" >&2
- exit 3
- ;;
- stop)
- do_stop
- ;;
- *)
- echo "Usage: codesyscontrol [start|stop]" >&2
- exit 3
- ;;
- esac
- :
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement