1#!/usr/bin/gmic
2
3skip "${1=}"
4
5# Retrieve relative path
6x "pwd >/tmp/pwd.txt"
7it /tmp/pwd.txt autocrop 10
8pwd={`"
9  path = crop();
10  base = 'gmic/html';
11  p = find(path,base);
12  p>0?(
13    l = size(path) - p - size(base);
14    copy(path,path[p + size(base)],l);
15    path[l] = _'/'; path[l+1] = 0):(path[0] = 0);
16  path"`}
17  is_pwd={['$pwd']!=0}
18
19# Upload file or directory.
20if "s = ['$1']; "$is_pwd" && (s==0 || s=='.')" # Synchronize current directory
21  e[] "Synchronize current directory '"${pwd}"' with 'SERVER"${pwd}"'.\n"
22  com="lftp ftp://"$GMIC_LOGIN":"$GMIC_PASSWD"@"$GMIC_FTP" -e \"mirror -RL . /www/gmic"${pwd}" ; quit\""
23  x $com
24
25elif $is_pwd" && isdir(['"$1"'])" # Synchronize specified directory
26  e[] "Synchronize directory '$1' with 'SERVER"${pwd}"$1'.\n"
27  com="lftp ftp://"$GMIC_LOGIN":"$GMIC_PASSWD"@"$GMIC_FTP" -e \"mirror -RL \\\"$1\\\" \\\"/www/gmic"${pwd}"$1\\\" ; quit\""
28  x $com
29
30elif isfile(['"$1"']) # Upload single file
31  if !$is_pwd pwd="/" fi
32  e[] "Upload file '$1' to 'SERVER"${pwd}"'.\n"
33  com="lftp ftp://"$GMIC_LOGIN":"$GMIC_PASSWD"@"$GMIC_FTP" -e \"put -O \\\"/www/gmic"${pwd}"\\\" \\\"$1\\\"; quit\""
34  x $com
35
36fi
37
38# Local Variables:
39# mode: sh
40# End:
41#
42# (End of G'MIC custom commands)
43