@@ -22,16 +22,16 @@ Usage on Linux
2222 docker run --rm -it --cap-add SYS_ADMIN --device /dev/fuse
2323 --name che-mount
2424 -v \$ {HOME}/.ssh:\$ {HOME}/.ssh
25- -v \$ {HOME}/.unison:\$ {HOME}/.unison
2625 -v /etc/group:/etc/group:ro
2726 -v /etc/passwd:/etc/passwd:ro
27+ -v <path-to-sync-profile>:/profile
2828 -u \$ (id -u \$ {USER})
2929 -v <local-mount>/:/mnthost codenvy/che-mount <ip> <port>
3030
3131Usage on Mac or Windows:
3232 docker run --rm -it --cap-add SYS_ADMIN --device /dev/fuse
3333 --name che-mount
34- -v ~/.ssh:/root/.ssh
34+ -v <path-to-sync-profile>:/profile
3535 -v <local-mount>/:/mnthost codenvy/che-mount <ip> <port>
3636
3737 <local-mount> Host directory to sync files, must end with a slash '/'
@@ -44,8 +44,12 @@ Usage on Mac or Windows:
4444parse_command_line () {
4545 if [ $# -eq 0 ]; then
4646 usage
47- exit
47+ return 1
4848 fi
49+
50+ # See if profile document was provided
51+ mkdir -p $HOME /.unison
52+ cp -rf /profile/default.prf $HOME /.unison/default.prf
4953}
5054
5155usage () {
@@ -61,47 +65,47 @@ debug() {
6165}
6266
6367error () {
64- printf " ${RED} ERROR:${NC} %s\n" " ${1} "
65- }
66-
67- error_exit () {
6868 echo " ---------------------------------------"
6969 error " !!!"
7070 error " !!! ${1} "
7171 error " !!!"
7272 echo " ---------------------------------------"
73+ return 1
74+ }
75+
76+ stop_sync () {
77+ echo " Received interrupt signal. Exiting."
7378 exit 1
7479}
7580
7681# See: https://sipb.mit.edu/doc/safe-shell/
7782set -u
7883
84+ # on callback, kill the last background process, which is `tail -f /dev/null` and execute the specified handler
85+ trap ' stop_sync' SIGHUP SIGTERM SIGINT
86+
7987init_logging
8088init_global_variables
8189parse_command_line " $@ "
8290
83- info " INFO: ECLIPSE CHE : Mounting user@$1 :/projects with SSHFS"
91+ info " INFO: (che mount) : Mounting user@$1 :/projects with SSHFS"
8492sshfs user@$1 :/projects /mntssh -p $2
8593status=$?
8694if [ $status -ne 0 ]; then
8795 error " ERROR: Fatal error occurred ($status )"
8896 exit 1
8997fi
90- info " INFO: ECLIPSE CHE : Successfully mounted user@$1 :/projects"
91- info " INFO: ECLIPSE CHE: Intial sync...Please wait."
98+ info " INFO: (che mount) : Successfully mounted user@$1 :/projects"
99+ info " INFO: (che mount): Initial sync...Please wait."
92100unison /mntssh /mnthost -batch -fat -silent -auto -prefer=newer -log=false > /dev/null 2>&1
93101status=$?
94102if [ $status -ne 0 ]; then
95103 error " ERROR: Fatal error occurred ($status )"
96104 exit 1
97105fi
98- info " INFO: ECLIPSE CHE: Background sync continues every ${UNISON_REPEAT_DELAY_IN_SEC} seconds."
106+ info " INFO: (che mount): Background sync continues every ${UNISON_REPEAT_DELAY_IN_SEC} seconds."
107+ info " INFO: (che mount): This terminal will block while the synchronization continues."
108+ info " INFO: (che mount): To stop, issue a SIGTERM or SIGINT, usually CTRL-C."
99109
100- # -repeat=watch doesn't work because SSHFS doesn't support inotify and
101- # unison-fsmonitor rely on inotify
102- unison /mntssh /mnthost -batch -retry 10 -fat -silent -copyonconflict -auto -prefer=newer -repeat=${UNISON_REPEAT_DELAY_IN_SEC} -log=false > /dev/null 2>&1
103- status=$?
104- if [ $status -ne 0 ]; then
105- error " ERROR: Fatal error occurred ($status )"
106- exit 1
107- fi
110+ # run application
111+ unison /mntssh /mnthost -batch -retry 10 -fat -silent -copyonconflict -auto -prefer=newer -repeat=${UNISON_REPEAT_DELAY_IN_SEC} -log=false > /dev/null 2>&1
0 commit comments