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