| OLD | NEW |
| (Empty) |
| 1 #!/bin/sh | |
| 2 # Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | |
| 3 # for details. All rights reserved. Use of this source code is governed by a | |
| 4 # BSD-style license that can be found in the LICENSE.md file. | |
| 5 | |
| 6 ### BEGIN INIT INFO | |
| 7 # Provides: fletch-configuration | |
| 8 # Required-Start: hostname mountall $syslog | |
| 9 # Required-Stop: | |
| 10 # Should-Start: | |
| 11 # Should-Stop: | |
| 12 # Default-Start: S | |
| 13 # Default-Stop: | |
| 14 # Description: Modify configuration based on files in the boot partition | |
| 15 ### END INIT INFO | |
| 16 | |
| 17 PATH=/sbin:/bin | |
| 18 | |
| 19 . /lib/init/vars.sh | |
| 20 . /lib/lsb/init-functions | |
| 21 | |
| 22 CONFIGURATION_DIR=/boot/fletch-configuration | |
| 23 FLETCH_HOSTNAME_CONF="$CONFIGURATION_DIR/hostname" | |
| 24 HOSTNAME_CONF="/etc/hostname" | |
| 25 FLETCH_HOSTS_CONF="$CONFIGURATION_DIR/hosts" | |
| 26 HOSTS_CONF="/etc/hosts" | |
| 27 | |
| 28 do_start () { | |
| 29 # Copy from source to dest if source exists. | |
| 30 log_action_msg "Running fletch configuration manager" | |
| 31 if [ -f $FLETCH_HOSTNAME_CONF ]; then | |
| 32 log_action_begin_msg "Updating $HOSTNAME_CONF" | |
| 33 | |
| 34 cp $FLETCH_HOSTNAME_CONF $HOSTNAME_CONF | |
| 35 chown root:root $HOSTNAME_CONF | |
| 36 chmod 644 $HOSTNAME_CONF | |
| 37 | |
| 38 HOSTNAME="$(cat /etc/hostname)" | |
| 39 hostname "$HOSTNAME" | |
| 40 ES=$? | |
| 41 log_action_end_msg $ES | |
| 42 | |
| 43 rm $FLETCH_HOSTNAME_CONF | |
| 44 fi | |
| 45 | |
| 46 if [ -f $FLETCH_HOSTS_CONF ]; then | |
| 47 log_action_begin_msg "Updating $HOSTS_CONF" | |
| 48 | |
| 49 cp $FLETCH_HOSTS_CONF $HOSTS_CONF | |
| 50 chown root:root $HOSTS_CONF | |
| 51 chmod 644 $HOSTS_CONF | |
| 52 | |
| 53 ES=$? | |
| 54 log_action_end_msg $ES | |
| 55 | |
| 56 rm $FLETCH_HOSTS_CONF | |
| 57 fi | |
| 58 log_action_msg "Done fletch configuration manager" | |
| 59 } | |
| 60 | |
| 61 do_status () { | |
| 62 # Currently status is always OK. | |
| 63 return 0; | |
| 64 } | |
| 65 | |
| 66 case "$1" in | |
| 67 start|"") | |
| 68 do_start | |
| 69 ;; | |
| 70 restart|reload|force-reload) | |
| 71 echo "Error: argument '$1' not supported" >&2 | |
| 72 exit 3 | |
| 73 ;; | |
| 74 stop) | |
| 75 # No-op | |
| 76 ;; | |
| 77 status) | |
| 78 do_status | |
| 79 exit $? | |
| 80 ;; | |
| 81 *) | |
| 82 echo "Usage: fletch-configuration [start|stop]" >&2 | |
| 83 exit 3 | |
| 84 ;; | |
| 85 esac | |
| OLD | NEW |