Skip to content
This repository has been archived by the owner on May 14, 2020. It is now read-only.

Commit

Permalink
Merge pull request #3 from yoctu/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
dzove855 authored Feb 6, 2019
2 parents a6a3bb5 + a183e9e commit 8a2a76b
Show file tree
Hide file tree
Showing 23 changed files with 367 additions and 308 deletions.
105 changes: 105 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/bin/bash

SELF="${BASH_SOURCE[0]##*/}"
NAME="${SELF%.sh}"

OPTS="svxEh"
USAGE="Usage: $SELF [$OPTS]"

HELP="
$USAGE
Options:
-s simulate
-v set -v
-x set -x
-e set -ve
-h Help
"

function _quit ()
{
local retCode="$1" msg="${@:2}"

echo -e "$msg"
exit $retCode
}

function _notify()
{
echo -e "\n\n\n\n\n################################## $* #####################################\n\n\n\n\n" >&2
}

while getopts "${OPTS}" arg; do
case "${arg}" in
s) _run="echo" ;;
v) set -v ;;
x) set -x ;;
e) set -ve ;;
h) _quit 0 "$HELP" ;;
?) _quit 1 "Invalid Argument: $USAGE" ;;
*) _quit 1 "$USAGE" ;;
esac
done
shift $((OPTIND - 1))

fileuuid="bck8:49f0d248-f21d-4a14-871d-31b007189081"
project="yoctapi"
ppa_repo="public"

trap '_quit 2 "An Error occured while running script"' ERR

_notify "Install dependencies"
sudo apt-get update >&/dev/null ; sudo apt-get install -y apt-transport-https devscripts debianutils jq gridsite-clients &>/dev/null
wget -qO - https://ppa.yoctu.com/archive.key | sudo apt-key add -

curl -s -o /tmp/jq -O -L https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64
chmod +x /tmp/jq
sudo mv /tmp/jq /usr/bin/jq

echo "deb https://ppa.yoctu.com/ all unstable" | sudo tee /etc/apt/sources.list
sudo apt-get update &>/dev/null
cd /tmp

sudo apt-get install yoctu-client-scripts &>/dev/null

_notify "Finished installing dependencies"

_notify "Fetch changelog"
cd -

filer-client.sh -U https://filer.test.flash.global -X get -u $fileuuid

mv /tmp/${project}-changelog debian/changelog

_notify "Fetched changelog"

_notify "Setup Github"
sudo -s curl -o /bin/git-to-deb.sh -O -L https://ppa.yoctu.com/git-to-deb.sh
sudo chmod +x /bin/git-to-deb.sh

git config --global user.email "[email protected]"
git config --global user.name "git"
_notify "Setup done"

_notify "Build package"

git-to-deb.sh -i >/dev/null

filer-client.sh -U https://filer.test.flash.global -c MISCELLANEOUS -n "${project}-changelog" -f debian/changelog -C "need=Changelog file for $project" -m "text/plain" -X update -u $fileuuid
_notify "Build done"

_notify "Rsync to ppa"
mv ../$project*.deb ../$project.deb
export LC_FLASH_PROJECT_ID="$project"

IFS='/' read nonused heads branch <<<$CPHP_GIT_REF
[[ "$heads" == "tags" ]] && branch="$heads"
export LC_FLASH_ARGS="project=$project ppa_repo=$ppa_repo git_branch=$branch flashGitRef=$CPHP_GIT_REF"
export LC_FLASH_YAML="000-default-flash-debian-script.yaml"

export LC_FLASH_BRANCH=$CPHP_GIT_REF && scp -P2222 -o StrictHostKeyChecking=no -i ~/.ssh/automate.key ../$project.deb [email protected]:/tmp/${LC_FLASH_PROJECT_ID}.deb
_notify "Rsync done"

rm -rf debian
5 changes: 1 addition & 4 deletions config/app.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
application_name="yosh"
application_name="yoctapi"
html_dir="${DOCUMENT_ROOT%/}/../html"
css_dir="${DOCUMENT_ROOT%/}/../css"
js_dir="${DOCUMENT_ROOT%/}/../js"
img_dir="${DOCUMENT_ROOT%/}/../img"
fonts_dir="${DOCUMENT_ROOT%/}/../fonts"
api_dir="${DOCUMENT_ROOT%/}../api"
etc_conf_dir="/etc/$application_name/"
login_method="auth::request"
login_page="login"
login_unauthorized="html::print::out ${html_dir}/login.html"
17 changes: 0 additions & 17 deletions config/dbconnector.sh

This file was deleted.

1 change: 0 additions & 1 deletion config/htpasswd

This file was deleted.

1 change: 0 additions & 1 deletion config/htpasswd.sh

This file was deleted.

3 changes: 0 additions & 3 deletions config/logger.sh
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
declare -A LOGGING
LOGGING['file':'method']="file"
LOGGING['file':'tag']="log"
13 changes: 0 additions & 13 deletions config/mysql.sh

This file was deleted.

3 changes: 1 addition & 2 deletions config/route.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
#ROUTE['/':'GET':'connect']="html::print::out ${html_dir}/home.html"

api_command="Api::call::function"
default_api_function="dbconnector"
default_api_function="Yoctapi::api::main"

# router="route::api::mode"
# router="route::check"
router="Route::api::mode"

# Defaults routes
#AUTH['/':'GET']="htpasswd"
Expand Down
34 changes: 34 additions & 0 deletions config/yoctapi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[public:assoc] YOCTAPI

# Read Credentials
YOCTAPI['route':'MATCHER':'read':'credentials':'host']="localhost"
YOCTAPI['route':'MATCHER':'read':'credentials':'user']="USER"
YOCTAPI['route':'MATCHER':'read':'credentials':'password']="PASSWORD"
YOCTAPI['route':'MATCHER':'read':'credentials':'database']="DATABASE"
YOCTAPI['route':'MATCHER':'read':'connector']="mysql"

# Write Credentials
YOCTAPI['route':'MATCHER':'write':'credentials':'host']="localhost"
YOCTAPI['route':'MATCHER':'write':'credentials':'user']="USER"
YOCTAPI['route':'MATCHER':'write':'credentials':'password']="PASSWORD"
YOCTAPI['route':'MATCHER':'write':'credentials':'database']="DATABASE"
YOCTAPI['route':'MATCHER':'write':'connector']="mysql"

# GET FILTERS
YOCTAPI['route':'MATCHER':'request':'get':'filter']="FILER1,FITLER2"
YOCTAPI['route':'MATCHER':'request':'get':'object']="OBJECT"
YOCTAPI['route':'MATCHER':'request':'get':'search']="SEARCH"
YOCTAPI['route':'MATCHER':'request':'get':'table']="TABLE"

# POST FILTERS
YOCTAPI['route':'MATCHER':'request':'post':'table']="TABLE"

# PUT FILTERS
YOCTAPI['route':'MATCHER':'request':'put':'search']="SEARCH"
YOCTAPI['route':'MATCHER':'request':'put':'table']="TABLE"

# DELETE FILTERS
YOCTAPI['route':'MATCHER':'request':'delete':'search']="SEARCH"
YOCTAPI['route':'MATCHER':'request':'delete':'table']="TABLE"

YOCTAPI['route':'bertrand':'request':'delete':'search']="SEARCH"
File renamed without changes.
1 change: 1 addition & 0 deletions debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7
12 changes: 12 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Source: yoctapi
Section: utils
Maintainer: Dzove855 <[email protected]>
Build-Depends: debhelper
Standards-Version: 0.8.20

Package: yoctapi
Architecture: all
Maintainer: Dzogovic Vehbo <[email protected]>
Priority: optional
Depends: jq, yosh, libyosh-gateway
Description: yoctapi (yoctu shell) - Micro Web Framework lib
6 changes: 6 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/make -f
%:
dh $@

override_dh_builddeb:
dh_builddeb -- -Zgzip
7 changes: 7 additions & 0 deletions debian/yoctapi.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
auth var/www/yoctapi/
bin var/www/yoctapi/
config var/www/yoctapi/
lib var/www/yoctapi/
public var/www/yoctapi/
README.md usr/share/yoctapi/doc/
dist/apache2/yoctapi.conf etc/apache2/sites-available/
24 changes: 24 additions & 0 deletions dist/apache2/yoctapi.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<VirtualHost *:80>

define documentroot /var/www/yoctapi/public

DocumentRoot ${documentroot}

<Directory ${documentroot}>
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
AddHandler cgi-script .sh

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /main.sh [NC,L]

DirectoryIndex main.sh

</Directory>

undefine documentroot

</VirtualHost>
128 changes: 0 additions & 128 deletions func/dbconnector.sh

This file was deleted.

Loading

0 comments on commit 8a2a76b

Please sign in to comment.