Advertisement
Guest User

CodeSys

a guest
Apr 15th, 2015
772
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.19 KB | None | 0 0
  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          codesyscontrol
  4. # Required-Start:    hostname $local_fs
  5. # Required-Stop:
  6. # Should-Start:
  7. # Default-Start:     2 3 4 5
  8. # Default-Stop:
  9. # Short-Description: Prepares and starts codesyscrontol
  10. # Description:       Prepares and starts codesyscrontol
  11. ### END INIT INFO
  12.  
  13. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  14. . /lib/init/vars.sh
  15.  
  16. make_mknod () {
  17.     #create node if not already there
  18.     if [ ! -c /dev/char_dev ]; then
  19.         echo "created node"
  20.         /bin/mknod /dev/char_dev c 100 0
  21.     fi
  22. }
  23.  
  24. do_start () {
  25.    
  26.     make_mknod 
  27.    
  28.     killall codesyscontrol.bin > /dev/null;
  29.    
  30.     export PlcConfigFile=/etc/CODESYSControl.cfg
  31.        
  32.     echo bcm2708_i2c.0 > /sys/bus/platform/drivers/bcm2708_i2c/unbind
  33.     echo 400000 > /sys/module/i2c_bcm2708/parameters/baudrate
  34.     echo bcm2708_i2c.0 > /sys/bus/platform/drivers/bcm2708_i2c/bind
  35.    
  36.     # 1 wire   
  37.     modprobe w1-gpio pullup=1
  38.     modprobe w1-therm
  39.  
  40.    
  41.     cd /root/
  42.     /usr/bin/codesyscontrol.bin > /tmp/codesyscontrol.log 2>&1 &
  43.     cd -
  44.    
  45.     sleep 1 && pgrep codesyscontrol > /dev/null && echo "codesyscontrol started" || echo "ERROR: codesyscontrol not started!";
  46.    
  47. }
  48.  
  49. do_backuplicenses () {
  50.    
  51.     # restore und backup ordner...
  52.     #
  53.     # backup immer
  54.     # restore wenn "restore" ordner nicht leer, und tar...
  55.     #
  56.  
  57.     echo "Backup licenses" 
  58.     ARCHIVE=/root/backup/3SLicenseInfo.tar
  59.     ARCHIVE_INFO=/root/cmact_licenses/info.lic
  60.  
  61.     date > $ARCHIVE_INFO
  62.     uname -a >> $ARCHIVE_INFO
  63.     cat /proc/cpuinfo >> $ARCHIVE_INFO
  64.     ifconfig -a >> $ARCHIVE_INFO
  65.  
  66.     ls -la /root/cmact_licenses/ >> $ARCHIVE_INFO
  67.  
  68.     tar cf $ARCHIVE /root/cmact_licenses /root/3SLicense.wbb > /dev/null
  69.    
  70. }
  71.  
  72. do_restorelicenses () {
  73.  
  74.     ARCHIVE=/root/restore/3SLicenseInfo.tar
  75.     NEWARCHIVE=/tmp/3SLicenseInfo.tar
  76.  
  77.     if [ -f $ARCHIVE ]; then
  78.    
  79.         mv $ARCHIVE /tmp/      
  80.         tar -xvf $NEWARCHIVE -C /
  81.         echo "Restored licenses"
  82.     fi
  83.  
  84. }
  85.  
  86. do_stop () {
  87.     /usr/bin/killall -2 codesyscontrol.bin
  88. }
  89.  
  90. case "$1" in
  91.   start|"")
  92.  
  93.     do_restorelicenses
  94.     do_backuplicenses
  95.  
  96.     do_start
  97.  
  98.  
  99.     ;;
  100.   restart|reload|force-reload|status)
  101.     echo "Error: argument '$1' not supported" >&2
  102.     exit 3
  103.     ;;
  104.   stop)
  105.     do_stop
  106.     ;;
  107.   *)
  108.     echo "Usage: codesyscontrol [start|stop]" >&2
  109.     exit 3
  110.     ;;
  111. esac
  112.  
  113. :
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement