Created
April 2, 2015 13:23
-
-
Save mushu8/62556029e7e8f9c1e104 to your computer and use it in GitHub Desktop.
call ws to update local json settings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. get the xcode plist file path | |
# 2. read server url from plist file | |
# 3. read json settings file name from plist file | |
# 4. create temporary file for curl body response | |
# 5. curl api/settings web service and get http code | |
# 6. if http code is 200, feed the settigns file with new json | |
# 7. clean temp file | |
# 1. info plist path | |
infoplist="${INFOPLIST_FILE}" | |
echo "infoplist path: "${infoplist} | |
# 2. read server URL | |
serverURL=`/usr/libexec/PlistBuddy -c "Print :ServerURL" ${infoplist}` | |
# 3. read json settings file name from plist file | |
settingsFileName=`/usr/libexec/PlistBuddy -c "Print :SettingsFILE" ${infoplist}`.json | |
echo "serverURL: "${serverURL} | |
echo "settingsFileName: "${settingsFileName} | |
# settings file path | |
settingsPath="${PROJECT_DIR}/Fabville-swift/${settingsFileName}" | |
#settingsPathTemp=/Users/alexandresagette/Development/Repositories/fabville-swift/Fabville-swift${settingsPath}-temp | |
echo "settingsPath: ${settingsPath}" | |
# 4. create temporary file for curl content | |
settingsPathTemp=${settingsPath}-temp | |
touch ${settingsPathTemp} | |
echo "settingsPathTemp: ${settingsPathTemp}" | |
# 5. curl api/settings web service and get http code | |
httpCode=`curl --request GET "${serverURL}/api/settings" --header 'Accept:application/version.v1' --write-out %{http_code} -o ${settingsPathTemp}` | |
echo "httpCode: ${httpCode}" | |
# 6. if http code is 200, feed the settigns file with new json | |
exitCode=0 | |
if [ $httpCode == 200 ] | |
then | |
cat ${settingsPathTemp} >> ${settingsPath} | |
else | |
exitCode=1 | |
fi | |
# 7. clean temp file | |
rm ${settingsPathTemp} | |
exit $exitCode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment