New scripts to get files

This commit is contained in:
nemunaire 2016-02-01 18:57:47 +01:00 committed by Pierre-Olivier Mercier
commit a8031452f7
3 changed files with 64 additions and 1 deletions

View file

@ -59,6 +59,18 @@ func exportThemes() (interface{}, error) {
}
}
func bindingFiles() (string, error) {
if files, err := fic.GetFiles(); err != nil {
return "", err
} else {
ret := ""
for _, file := range files {
ret += fmt.Sprintf("%s;%s\n", file.GetOrigin(), file.Path)
}
return ret, nil
}
}
func getTheme(args []string) (fic.Theme, error) {
if tid, err := strconv.Atoi(string(args[0])); err != nil {
return fic.Theme{}, err
@ -99,7 +111,9 @@ func listTheme(args []string, body []byte) (interface{}, error) {
return getExercice(args)
}
} else if len(args) == 1 {
if args[0] == "themes.json" {
if args[0] == "files-bindings" {
return bindingFiles()
} else if args[0] == "themes.json" {
return exportThemes()
} else {
return getTheme(args)

23
admin/get_files.sh Executable file
View file

@ -0,0 +1,23 @@
#!/bin/sh
BASEURL="http://localhost:8081"
BASEURI="https://srs.epita.fr/owncloud/remote.php/webdav/FIC 2016"
CLOUDUSER='fic'
CLOUDPASS='f>t\nV33R|(+?$i*'
if [ $# -gt 0 ]
then
WHERE=$1
else
WHERE="files"
fi
curl -q -f ${BASEURL}/api/themes/files-bindings | while read l
do
FROM=$(echo "$l" | cut -d ";" -f 1)
DEST=$(echo "$l" | cut -d ";" -f 2)
mkdir -p $(dirname "${WHERE}${DEST}")
wget -O "${WHERE}${DEST}" --user "${CLOUDUSER}" --password "${CLOUDPASS}" "${BASEURI}${FROM}"
done