-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy_user_media.sh
executable file
·53 lines (41 loc) · 1.41 KB
/
deploy_user_media.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
#!/bin/bash
# exit on first error
set -e
# can fail in the case of simlinks
ADMIN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
source ${ADMIN_DIR}/functions.sh
# the kobocat shell be running
if ! koboadm_check_components_up "kobocat"; then exit 1; fi
echo -e "${RED}WARNING: you are about to overwrite the KoboToolbox USER-MEDIA data,${NC}"
echo -e "${RED} are you sure you made the most recent backup before? (y/n)${NC}"
read answer
if [ "$answer" == "${answer#[Yy]}" ]; then exit 0; fi
# select user-media backup archive
echo "Enter user-media kobocat filename from the list below:"
koboadm_ls kobocat "/srv/backups"
echo ">"
read ARCH_KOBOCAT
ARCH_KOBOCAT="/srv/backups/${ARCH_KOBOCAT}"
if ! koboadm_check_container_file kobocat "${ARCH_KOBOCAT}"; then exit 0; fi
echo
# deploy user media
echo "Deploying..."
RESTART_SRV="0"
if koboadm_check_components_up "${SRV}"
then
RESTART_SRV="1"
koboadm_stop_components "${SRV}"
fi
CNAME=`koboadm_cname kobocat`
docker exec ${CNAME} bash -c "tar xvpf ${ARCH_KOBOCAT} --directory=/srv/src/kobocat/media media"
if [ "${RESTART_SRV}" == "1" ]
then
docker-compose start ${SRV}
fi
echo "done"
echo
echo -e "${YELLOW}Check that media-files ownership is correct:${NC}"
echo -e "${YELLOW}UWSGI_USER =" \
$(docker exec ${CNAME} bash -c "printenv UWSGI_USER") "${NC}"
echo -e "${YELLOW}UWSGI_GROUP =" \
$(docker exec ${CNAME} bash -c "printenv UWSGI_GROUP") "${NC}"