File: ltsp-open

package info (click to toggle)
ltsp 5.5.4-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,440 kB
  • ctags: 359
  • sloc: sh: 5,106; ansic: 1,590; perl: 280; python: 197; makefile: 171; lex: 152; yacc: 59
file content (32 lines) | stat: -rwxr-xr-x 854 bytes parent folder | download | duplicates (5)
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
#!/bin/sh

file=$1
filename=${file##*/}
path=${file%/*}

[ -n "${REMOTE_APPS_TMPDIR}" ] || exit

# What is mounted from the server?
while read dev mnt type rest; do
    if [ -n "$(echo $dev|grep :)" ]; then
        path_mounted=$(echo $dev|cut -d: -f2)
        if [ -n "$(echo ${path}|grep ${path_mounted})" ]; then
            # File path is subdirectory of path_mounted, so 
            # should be server-accessible
            export FILE_ACCESSIBLE=1
            break
        else
            export FILE_ACCESSIBLE=0
        fi
    fi
done </proc/mounts

if [ "${FILE_ACCESSIBLE}" = "1" ]; then
    ltsp-remoteapps xdg-open ${file}
else
    # We need to scp the file to a viewable path on the server
    newfile="${REMOTE_APPS_TMPDIR}/${filename}"
    cp "${file}" "${newfile}"
	chmod 600 "${newfile}"
    ltsp-remoteapps xdg-open "${newfile}"
fi