Bash/Php const+func with source -> update bootloader
This commit is contained in:
parent
3a9b6b8d5e
commit
d4b14c1d02
10
daemon
10
daemon
|
@ -1,11 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
c=0;
|
ABSPATH=$( dirname $(realpath $0) );
|
||||||
|
|
||||||
while [ 1 ]; do
|
$ABSPATH/lib/mfrc522/loop;
|
||||||
|
|
||||||
echo "daemon launched $c";
|
|
||||||
sleep 1;
|
|
||||||
|
|
||||||
c=`expr $c + 1`;
|
|
||||||
done;
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once __DIR__.'/../../include/const';
|
require_once __DIR__.'/../../include/php/const';
|
||||||
|
|
||||||
function api_fetch(){
|
function api_fetch(){
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once __DIR__.'/../../include/const';
|
require_once __DIR__.'/../../include/php/const';
|
||||||
|
|
||||||
function api_request(){
|
function api_request(){
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once __DIR__.'/../../include/const';
|
require_once __DIR__.'/../../include/php/const';
|
||||||
|
|
||||||
|
|
||||||
/* [1] Function that generates a random secret
|
/* [1] Function that generates a random secret
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once __DIR__.'/../../include/const';
|
require_once __DIR__.'/../../include/php/const';
|
||||||
|
|
||||||
|
|
||||||
function cyclichash_hash(){
|
function cyclichash_hash(){
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once __DIR__.'/../../include/const';
|
require_once __DIR__.'/../../include/php/const';
|
||||||
|
|
||||||
|
|
||||||
function cyclichash_new(){
|
function cyclichash_new(){
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# RESET OUTPUT BUFFER
|
||||||
|
|
||||||
|
# MAIN DIRECTORIES
|
||||||
|
#export ROOT_DIR="$"/home/sats/satsd;
|
||||||
|
export ROOT_DIR="/home/xdrm-brackets/SANDBOX/sats-local";
|
||||||
|
export LOG_DIR="$ROOT_DIR/log";
|
||||||
|
export DATA_DIR="$ROOT_DIR/data";
|
||||||
|
export CONF_DIR="$ROOT_DIR/conf";
|
||||||
|
#export SOURCE_DIR="$ROOT_DIR./source";
|
||||||
|
export SOURCE_DIR="/home/xdrm-brackets/Desktop/git.xdrm.io/logauth-sats";
|
||||||
|
export TMP_DIR="$ROOT_DIR/tmp";
|
||||||
|
|
||||||
|
# CONFIGURATION FILES
|
||||||
|
export SECRET_CONF="$CONF_DIR/machine.secret";
|
||||||
|
export STATE_CONF="$CONF_DIR/machine.state";
|
||||||
|
export BRANCH_CONF="$CONF_DIR/machine.branch";
|
||||||
|
export ID_CONF="$CONF_DIR/machine.id";
|
||||||
|
export URL_CONF="$CONF_DIR/api.url";
|
||||||
|
export AUTH_CONF="$CONF_DIR/auth.list";
|
||||||
|
|
||||||
|
# LOG FILES
|
||||||
|
export BOOT_LOG="$CONF_DIR/boot.log";
|
||||||
|
export DAEMON_LOG="$CONF_DIR/daemon.log";
|
||||||
|
export INSTALL_LOG="$CONF_DIR/install-source.log";
|
||||||
|
export UPDATE_LOG="$CONF_DIR/update.log";
|
||||||
|
|
||||||
|
# DATA FILES
|
||||||
|
export ACCESS_DATA="$DATA_DIR/access.data";
|
||||||
|
|
||||||
|
# SETTINGS
|
||||||
|
export SECRET_SIZE=250;
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
# [1] Launches external script
|
||||||
|
####################################################
|
||||||
|
# $1 - dependency file
|
||||||
|
syscall(){
|
||||||
|
# (1) Check file #
|
||||||
|
test -z $1 && exit;
|
||||||
|
test ! -f $1 && exit;
|
||||||
|
|
||||||
|
# (2) Call and catch output #
|
||||||
|
OUT=$($1);
|
||||||
|
|
||||||
|
# (3) Clean output : remove leading/ending spaces #
|
||||||
|
OUT=$(echo $OUT | tr '\n' '\x' | sed 's/^[ \t\x]*//g' | tr '\x' '\n');
|
||||||
|
OUT=$(echo $OUT | tr '\n' '\x' | sed 's/[ \t\x]*$//g' | tr '\x' '\n');
|
||||||
|
|
||||||
|
# (4) Manage result #
|
||||||
|
return $OUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
# [2] Log management
|
||||||
|
####################################################
|
||||||
|
# $1 - error message
|
||||||
|
# $2 - feature
|
||||||
|
# $3 - flag
|
||||||
|
slog(){
|
||||||
|
|
||||||
|
echo $(date +%s)." [$2] $1" >> $LOG_DIR."/$3.log";
|
||||||
|
|
||||||
|
}
|
|
@ -9,7 +9,7 @@
|
||||||
define('DATA_DIR', ROOT_DIR.'/data');
|
define('DATA_DIR', ROOT_DIR.'/data');
|
||||||
define('CONF_DIR', ROOT_DIR.'/conf');
|
define('CONF_DIR', ROOT_DIR.'/conf');
|
||||||
#define('SOURCE_DIR', ROOT_DIR.'/source');
|
#define('SOURCE_DIR', ROOT_DIR.'/source');
|
||||||
define('SOURCE_DIR', ROOT_DIR.'/home/xdrm-brackets/Desktop/git.xdrm.io/logauth-sats');
|
define('SOURCE_DIR', '/home/xdrm-brackets/Desktop/git.xdrm.io/logauth-sats');
|
||||||
define('TMP_DIR', ROOT_DIR.'/tmp');
|
define('TMP_DIR', ROOT_DIR.'/tmp');
|
||||||
|
|
||||||
# CONFIGURATION FILES
|
# CONFIGURATION FILES
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once __DIR__.'/../../include/const';
|
require_once __DIR__.'/../../include/php/const';
|
||||||
|
|
||||||
|
|
||||||
function mfrc522_read(){
|
function mfrc522_read(){
|
||||||
|
|
13
update
13
update
|
@ -1,14 +1,19 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
|
__DIR__=$(dirname $(realpath $0));
|
||||||
|
|
||||||
|
source $__DIR__/lib/include/bash/const;
|
||||||
|
source $__DIR__/lib/include/bash/func;
|
||||||
|
|
||||||
# [1] Send data + fetch configuration
|
# [1] Send data + fetch configuration
|
||||||
/home/sats/satsd/source/lib/api/sync;
|
$SOURCE_DIR/lib/api/sync;
|
||||||
|
|
||||||
test $? -ne 0 && exit 127;
|
test $? -ne 0 && exit 127;
|
||||||
|
|
||||||
# [2] Update source
|
# [2] Update source
|
||||||
BRANCH=$(cat /home/sats/satsd/conf/machine.branch);
|
BRANCH=$(cat $BRANCH_CONF);
|
||||||
|
|
||||||
cd /home/sats/satsd/source/;
|
cd $SOURCE_DIR
|
||||||
git checkout $BRANCH;
|
git checkout $BRANCH;
|
||||||
test $? -ne 0 && exit 127;
|
test $? -ne 0 && exit 127;
|
||||||
git pull origin $BRANCH;
|
git pull origin $BRANCH;
|
||||||
|
|
Loading…
Reference in New Issue