Deleting file: libre-streamer.py replaced by abyss.py
[libre-streamer.git] / upload_config.sh
CommitLineData
af3a72cf
LMM
1#!/usr/bin/env bash
2# This file is part of Libre-Streamer.
3#
4# Libre-Streamer is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version.
8#
9# Libre-Streamer is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with Libre-Streamer. If not, see <http://www.gnu.org/licenses/>.
16#
17# Copyright (C) 2014 Nico Cesar
18
19if [ $# -lt 1 ]
20then
21 echo $#
22 echo "usage: $0 elphel_camera_IP_address [config.xml] [/etc/autocampars.xml]"
23fi
24
25if [ "x$2" = "x" ]
26then
27 config_file=config.xml
28else
29 config_file=$2
30fi
31
32if [ "x$3" = "x" ]
33then
34 dest_file=/etc/autocampars.xml
35else
36 dest_file=$2
37fi
38
39echo -n "pinging $1 ... "
40ping -c2 $1 > /dev/null
41RESULT=$?
42
43if [ $RESULT -ne 0 ]
44then
45 echo cant ping $1
46 exit 1
47fi
48echo OK
49
50#do an url encode of the file
51python -c 'import sys,urllib; print urllib.urlencode([("content",sys.stdin.read())])' < $config_file > /tmp/tmp_file
52
53#upload to the camera
54curl -0 http://$1/admin-bin/editcgi.cgi?file= -d "save_file=/etc/autocampars.xml" -d "mode=0100644" -d "convert_crlf_to_lf=on" -d '@/tmp/tmp_file' | grep "Wrote"
55RESULT=$?
56
57if [ $RESULT -ne 0 ]
58then
59 echo problems loading the config
60 exit 1
61fi
62exit 0