-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlocal_deploy_sshfs.sh
executable file
·56 lines (44 loc) · 1.07 KB
/
local_deploy_sshfs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
function _log {
D=$(date +"%Y%m%dT%H:%M:%S")
echo -e $D "$@"
}
function log_error {
_log "\e[0;31mERROR\e[0m : $@"
exit -1
}
function log_warn {
ISSUE=$(($ISSUE + 1 ))
_log "\e[0;33mWARN\e[0m : $@"
}
function log_info {
_log "\e[1;32mINFO\e[0m : $@"
}
function remote_exec {
ssh -t $REMOTE_HOST "sh -lc \"set -e;$@\""
}
####### CONFIGURATION #######
export MOUNT_POINT=/home/steki/addons
export REMOTE_HOST=hassio
#### END CONFIGURATION ######
L=$(LANG=C df -h ${MOUNT_POINT}|grep -c hassio)
if [ $L -eq 1 ]; then
#replace...
log_info "already mounted"
else
log_info "mounting sshfs"
sshfs ${REMOTE_HOST}:/addons ${MOUNT_POINT} || ( log_error "failed sshfs mount" )
fi
rm -rf ${MOUNT_POINT}/borg-backup ||:
mkdir -p ${MOUNT_POINT}/borg-backup
cp -a * ${MOUNT_POINT}/borg-backup/
log_info "deployed source"
CMD="ha addons reload"
remote_exec "$CMD"
CMD="ha addons rebuild local_borg-backup"
remote_exec "$CMD"
CMD="ha addons restart local_borg-backup"
remote_exec "$CMD"
sleep 2
CMD="ha addons logs local_borg-backup"
remote_exec "$CMD"