Skip to content

Commit fc4f5a1

Browse files
committed
Add replication script and merge network settings (static/dhcp)
1 parent 1d7e0ff commit fc4f5a1

File tree

6 files changed

+75
-8
lines changed

6 files changed

+75
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# Changelog
22

3-
## 1.17.0 (TBD)
3+
## 1.17.0 (2017-11-01)
44

55
* Output more detailed info when creating a backup
66
* Ensure license.asc has correct permissions
7+
* Fix minor issues in 'backup' script
8+
* Add 'replication' script for handling replication settings
9+
* Merge network settings commands for dhcp/static
710

811
## 1.16.0 (2017-10-02)
912

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This repository contains bash scripts, ansible roles, and other files needed to
1111
* Ansible 1.5.x
1212
* curl
1313
* sha1sum (from core-utils)
14+
* [symlinktool](https://github.com/aw/tinycore-symlinktool) for running backups
1415

1516
## Ansible roles
1617

group_vars/images

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ admin_type: LIVE IMAGE
55
admin_type_lowcase: live image
66
ssh_path: /usr/local/etc/ssh
77

8-
jidoteki_admin_version: 1.16.0
8+
jidoteki_admin_version: 1.17.0

roles/admin/tasks/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
- update_debug.sh
6868
- update_license.sh
6969
- update_logs.sh
70+
- update_replication.sh
7071
- update_services.sh
7172
- update_settings.sh
7273
- update_storage.sh
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/sh
2+
#
3+
# Generic script for updating the replication settings
4+
#
5+
# Copyright (c) 2013-2017 Alex Williams, Unscramble. See the LICENSE file (MIT).
6+
# https://unscramble.co.jp
7+
#
8+
# VERSION: {{ jidoteki_admin_version }}
9+
10+
set -u
11+
set -e
12+
13+
if [ -f "/tmp/update_replication.sh.task" ]; then
14+
echo "already running"
15+
exit 1
16+
fi
17+
touch /tmp/update_replication.sh.task
18+
19+
admin_dir="{{ admin_path }}"
20+
uploads_dir="${admin_dir}/home/sftp/uploads"
21+
22+
fail_and_exit() {
23+
rm -f /tmp/update_replication.sh.task
24+
echo "[`date +%s`][{{ admin_type }}] Unable to update replication settings" 2>&1 | tee -a "${admin_dir}/log/update_replication.log"
25+
exit 1
26+
}
27+
28+
################
29+
30+
move_settings_files() {
31+
cd "${uploads_dir}"
32+
33+
if [[ ! -f "replication.json" && ! -f "replication.conf" ]]; then return 1; fi
34+
35+
if [ -f "replication.json" ]; then
36+
mv -f replication.json ${admin_dir}/etc/
37+
chmod 640 "${admin_dir}/etc/replication.json" ; chown root:admin "${admin_dir}/etc/replication.json"
38+
fi
39+
40+
if [ -f "replication.conf" ]; then
41+
mv -f replication.conf /usr/local/etc/
42+
chmod 640 "/usr/local/etc/replication.conf" ; chown root:admin "/usr/local/etc/replication.conf"
43+
fi
44+
}
45+
46+
save_replication_settings() {
47+
${admin_dir}/bin/replication.sh || return 1
48+
}
49+
50+
################
51+
52+
# Run all the tasks
53+
echo "[`date +%s`][{{ admin_type }}] Updating replication settings. Please wait.." 2>&1 | tee -a "${admin_dir}/log/update_replication.log"
54+
55+
move_settings_files && \
56+
save_replication_settings || fail_and_exit
57+
58+
echo "[`date +%s`][{{ admin_type }}] Updating replication settings successful" 2>&1 | tee -a "${admin_dir}/log/update_replication.log"
59+
60+
rm -f /tmp/update_replication.sh.task
61+
62+
exit 0

roles/admin/templates/wrapper.sh.j2

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,8 @@ case "${SSH_ORIGINAL_COMMAND}" in
3535
sudo ${admin_dir}/bin/update_license.sh && \
3636
backup_data
3737
;;
38-
"settings static")
39-
sudo ${admin_dir}/bin/update_settings.sh static && \
40-
backup_data
41-
;;
42-
"settings dhcp")
43-
sudo ${admin_dir}/bin/update_settings.sh dhcp && \
38+
"settings")
39+
sudo ${admin_dir}/bin/update_settings.sh "$1" && \
4440
backup_data
4541
;;
4642
"token")
@@ -74,6 +70,10 @@ case "${SSH_ORIGINAL_COMMAND}" in
7470
sudo ${admin_dir}/bin/update_backup.sh "$1" && \
7571
backup_data
7672
;;
73+
"replication")
74+
sudo ${admin_dir}/bin/update_replication.sh && \
75+
backup_data
76+
;;
7777
*)
7878
exit 1
7979
;;

0 commit comments

Comments
 (0)