2014-03-24 23:22:34 +01:00
|
|
|
#! /bin/bash
|
|
|
|
|
2014-03-27 16:05:23 +01:00
|
|
|
file_path=$1
|
|
|
|
filename="${file_path##*/}"
|
|
|
|
|
|
|
|
#base_instance_path and airtime_conf_path are common to all saas instances
|
|
|
|
base_instance_path=/mnt/airtimepro/instances/
|
|
|
|
airtime_conf_path=/etc/airtime/airtime.conf
|
|
|
|
|
|
|
|
#maps the instance_path to the url
|
|
|
|
vhost_file=/mnt/airtimepro/system/vhost.map
|
|
|
|
|
|
|
|
#instance_path will look like 1/1384, for example
|
|
|
|
instance_path=$(echo $file_path | grep -Po "(?<=($base_instance_path)).*?(?=/srv)")
|
|
|
|
|
2014-03-27 16:09:18 +01:00
|
|
|
#post request url - http://bananas.airtime.pro/rest/media, for example
|
2014-03-27 16:05:23 +01:00
|
|
|
url=http://
|
2014-03-27 16:09:18 +01:00
|
|
|
url+=$(grep -E $instance_path $vhost_file | awk '{print $1;}')
|
2014-03-27 16:05:23 +01:00
|
|
|
url+=/rest/media
|
|
|
|
|
|
|
|
#path to specific instance's airtime.conf
|
|
|
|
instance_conf_path=$base_instance_path$instance_path$airtime_conf_path
|
|
|
|
|
2014-03-27 16:09:18 +01:00
|
|
|
api_key=$(sudo awk -F "=" '/api_key/ {print $2}' $instance_conf_path)
|
2014-03-27 16:05:23 +01:00
|
|
|
|
2014-03-27 16:11:10 +01:00
|
|
|
curl $url -u $api_key":" -X POST -F "file=@$file_path" -F "name=$filename"
|