Creato sistema di deploy (INPROGRESS)
Importate librerie fondamentali: Logger (UNTESTED) System (UNTESTED) Dao (INCOMPLETE)
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
PROJECT_NAME="I Fatti di Napoli 2.0"
|
||||
APPLICATION_BUILDNAME="fdn2"
|
||||
|
||||
###########################
|
||||
####### APACHE DATA #######
|
||||
###########################
|
||||
APACHE2_USER="www-data"
|
||||
APACHE2_GROUP="www-data"
|
||||
APACHE2_DOCUMENTROOT="/var/www"
|
||||
|
||||
|
||||
###########################
|
||||
##### SYSTEM DETAILS ######
|
||||
###########################
|
||||
SYSTEM_LOG_PATH="/var/log/asdynamics"
|
||||
SYSTEM_PRIVATE="/home/asdynamics/private"
|
||||
SYSTEM_STORAGE="/home/asdynamics/storage"
|
||||
|
||||
|
||||
###################################
|
||||
##### APPLICATION ESSENTIALS ######
|
||||
###################################
|
||||
APPLICATION_PUBLIC="$APACHE2_DOCUMENTROOT/$APPLICATION_BUILDNAME"
|
||||
APPLICATION_PRIVATE="$SYSTEM_PRIVATE/$APPLICATION_BUILDNAME"
|
||||
APPLICATION_STORAGE="$SYSTEM_STORAGE/$APPLICATION_BUILDNAME"
|
||||
|
||||
APPLICATION_LOG_PATH="$SYSTEM_LOG_PATH/$APPLICATION_BUILDNAME"
|
||||
APPLICATION_XSENDFILE_PATH="/tmp/xsend/$APPLICATION_BUILDNAME"
|
||||
|
||||
|
||||
####################################
|
||||
##### OTHER APPLICATION PATHS ######
|
||||
####################################
|
||||
APPLICATION_MEDIA_PATH="$APPLICATION_STORAGE/media"
|
||||
APPLICATION_BACKUPS_PATH="$APPLICATION_STORAGE/backups"
|
||||
APPLICATION_TMP_PATH="$APPLICATION_STORAGE/tmp"
|
||||
APPLICATION_CONFIG_PATH="$APPLICATION_PRIVATE/common"
|
||||
APPLICATION_BINARY_PATH="$APPLICATION_PRIVATE/bin"
|
||||
@@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
|
||||
###########################
|
||||
#### MYSQL DATABASES ######
|
||||
###########################
|
||||
MYSQL_CONNECTION_STRING=""
|
||||
|
||||
declare -A MYSQL_DB_CONTENT_TABLES
|
||||
declare -A MYSQL_DB_CONFIG_TABLES
|
||||
|
||||
MYSQL_DB_CONTENT_TABLES=()
|
||||
MYSQL_DB_CONFIG_TABLES=()
|
||||
|
||||
while read line || [ -n "$line" ];
|
||||
do
|
||||
if echo $line | grep -P "([=][>]).*([=][>])" &>/dev/null
|
||||
then
|
||||
group=$(echo "$line" | sed -r 's/^\s*(\S+)\s*[=][>]\s*(\S+)\s*[=][>]\s*(.+)$/\1/')
|
||||
table=$(echo "$line" | sed -r 's/^\s*(\S+)\s*[=][>]\s*(\S+)\s*[=][>]\s*(.+)$/\2/')
|
||||
query=$(echo "$line" | sed -r 's/^\s*(\S+)\s*[=][>]\s*(\S+)\s*[=][>]\s*(.+)$/\3/')
|
||||
if [ "$group" = "content" ]; then
|
||||
MYSQL_DB_CONTENT_TABLES["$table"]="$query"
|
||||
elif [ "$group" = "config" ]; then
|
||||
MYSQL_DB_CONFIG_TABLES["$table"]="$query"
|
||||
fi
|
||||
fi
|
||||
done < dbCreation.mysql
|
||||
|
||||
|
||||
#MYSQL_DB_CONTENT_TABLES=( ["tizi"]="create table tizi" ["posti"]="create table posti" )
|
||||
|
||||
|
||||
###########################
|
||||
#### MONGO DATABASES ######
|
||||
###########################
|
||||
MONGO_CONNECTION_STRING=""
|
||||
|
||||
declare -A MONGO_DB_CONTENT_COLLECTIONS
|
||||
declare -A MONGO_DB_CONFIG_COLLECTIONS
|
||||
|
||||
MONGO_DB_CONTENT_COLLECTIONS=()
|
||||
MONGO_DB_CONFIG_COLLECTIONS=()
|
||||
|
||||
while read line || [ -n "$line" ];
|
||||
do
|
||||
if echo $line | grep -P "([=][>]).*([=][>])" &>/dev/null
|
||||
then
|
||||
group=$(echo "$line" | sed -r 's/^\s*(\S+)\s*[=][>]\s*(\S+)\s*[=][>]\s*(.+)$/\1/')
|
||||
table=$(echo "$line" | sed -r 's/^\s*(\S+)\s*[=][>]\s*(\S+)\s*[=][>]\s*(.+)$/\2/')
|
||||
query=$(echo "$line" | sed -r 's/^\s*(\S+)\s*[=][>]\s*(\S+)\s*[=][>]\s*(.+)$/\3/')
|
||||
if [ "$group" = "content" ]; then
|
||||
MONGO_DB_CONTENT_COLLECTIONS["$table"]="$query"
|
||||
elif [ "$group" = "config" ]; then
|
||||
MONGO_DB_CONFIG_COLLECTIONS["$table"]="$query"
|
||||
fi
|
||||
fi
|
||||
done < dbCreation.mongo
|
||||
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
#!/bin/bash
|
||||
|
||||
###########
|
||||
# Lo script utilizza tre possibili environment: Produzione, Test e Locale
|
||||
# Permette cinque operazioni su database: Drop and rebuild all, Drop and rebuild all content, Drop and rebuild config, Add missing tables e Skip
|
||||
###########
|
||||
|
||||
source "buildLibs"
|
||||
|
||||
OPTION_HELP=false # -h
|
||||
|
||||
ENVIRONMENT_PRODUCTION=false # -p
|
||||
ENVIRONMENT_TEST=false # -t
|
||||
ENVIRONMENT_LOCAL=false # -l
|
||||
|
||||
DATABASE_DROP_ALL=false # -D
|
||||
DATABASE_DROP_CONTENT=false # -C
|
||||
DATABASE_DROP_CONFIG=false # -c
|
||||
DATABASE_FIX=false # -f
|
||||
DATABASE_SKIP=false # -s
|
||||
|
||||
DEFAULT_CONFIG_FILE=".build.config"
|
||||
|
||||
DEFAULT_DATABASE_FILE=".build_db.config"
|
||||
|
||||
USE_CONFIG_FILE="$DEFAULT_CONFIG_FILE"
|
||||
USE_DATABASE_FILE="$DEFAULT_DATABASE_FILE"
|
||||
|
||||
while getopts ":hptlDCcfs" optname
|
||||
do
|
||||
case "$optname" in
|
||||
"h")
|
||||
OPTION_HELP=true
|
||||
;;
|
||||
"p")
|
||||
ENVIRONMENT_PRODUCTION=true
|
||||
;;
|
||||
"t")
|
||||
ENVIRONMENT_TEST=true
|
||||
;;
|
||||
"l")
|
||||
ENVIRONMENT_LOCAL=true
|
||||
;;
|
||||
"D")
|
||||
DATABASE_DROP_ALL=true
|
||||
;;
|
||||
"C")
|
||||
DATABASE_DROP_CONTENT=true
|
||||
;;
|
||||
"c")
|
||||
DATABASE_DROP_CONFIG=true
|
||||
;;
|
||||
"f")
|
||||
DATABASE_FIX=true
|
||||
;;
|
||||
"s")
|
||||
DATABASE_SKIP=true
|
||||
;;
|
||||
"?")
|
||||
echo "Invalid option -$OPTARG"
|
||||
;;
|
||||
":")
|
||||
echo "No argument value for option $OPTARG"
|
||||
;;
|
||||
*)
|
||||
# Should not occur
|
||||
echo "Unknown error while processing options"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$ENVIRONMENT_PRODUCTION" = false ] && [ "$ENVIRONMENT_TEST" = false ] && [ "$ENVIRONMENT_LOCAL" = false ]; then
|
||||
OPTION_HELP=true
|
||||
fi
|
||||
|
||||
if [ $OPTION_HELP = true ]; then
|
||||
help
|
||||
exit 0
|
||||
fi
|
||||
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
if [ "$1" != "" ]; then
|
||||
USE_CONFIG_FILE="$1"
|
||||
fi
|
||||
|
||||
if [ -f "$USE_CONFIG_FILE" ]; then
|
||||
source "$USE_CONFIG_FILE"
|
||||
else
|
||||
printf "Impossibile Leggere il file di configurazione '$USE_CONFIG_FILE')\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f "$USE_DATABASE_FILE" ]; then
|
||||
source "$USE_DATABASE_FILE"
|
||||
else
|
||||
printf "Impossibile Leggere il file di configurazione del database '$USE_DATABASE_FILE')\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -w "$APACHE2_DOCUMENTROOT" ] || [ ! -w "$SYSTEM_PRIVATE" ] || [ ! -w "$SYSTEM_STORAGE" ] || [ ! -w "$SYSTEM_LOG_PATH" ]; then
|
||||
printf "Permessi insufficienti per eseguire lo script (sudo?)\n"
|
||||
if [ ! -w "$APACHE2_DOCUMENTROOT" ]; then
|
||||
printf "Impossibile scrivere in '$APACHE2_DOCUMENTROOT'\n"
|
||||
fi
|
||||
if [ ! -w "$SYSTEM_PRIVATE" ]; then
|
||||
printf "Impossibile scrivere in '$SYSTEM_PRIVATE'\n"
|
||||
fi
|
||||
if [ ! -w "$SYSTEM_STORAGE" ]; then
|
||||
printf "Impossibile scrivere in '$SYSTEM_STORAGE'\n"
|
||||
fi
|
||||
if [ ! -w "$SYSTEM_LOG_PATH" ]; then
|
||||
printf "Impossibile scrivere in '$SYSTEM_LOG_PATH'\n"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
printf "Asdynamics Application Build/Deploy Script\n"
|
||||
if [ -f .logo ]; then
|
||||
cat .logo
|
||||
fi
|
||||
|
||||
if [ "$ENVIRONMENT_PRODUCTION" = true ]; then
|
||||
deploy_production_env
|
||||
elif [ "$ENVIRONMENT_TEST" = true ]; then
|
||||
deploy_test_env
|
||||
elif [ "$ENVIRONMENT_LOCAL" = true ]; then
|
||||
deploy_local_env
|
||||
fi
|
||||
|
||||
if [ "$DATABASE_DROP_ALL" = true ]; then
|
||||
database_rebuild_content
|
||||
database_rebuild_config
|
||||
elif [ "$DATABASE_DROP_CONTENT" = true ]; then
|
||||
database_rebuild_content
|
||||
elif [ "$DATABASE_DROP_CONFIG" = true ]; then
|
||||
database_rebuild_config
|
||||
elif [ "$DATABASE_FIX" = true ]; then
|
||||
database_add_missing
|
||||
elif [ "$DATABASE_SKIP" = false ]; then
|
||||
database_add_missing
|
||||
fi
|
||||
|
||||
|
||||
@@ -0,0 +1,271 @@
|
||||
#!/bin/bash
|
||||
|
||||
## Funzioni utilizzate da build
|
||||
|
||||
#Stampa i comandi possibili
|
||||
function help() {
|
||||
printf "\n"
|
||||
printf "build [-h] -[ptl] -[DCcfs] [config_file]\n"
|
||||
printf "\n"
|
||||
printf "Specificare il config_file solo se non si desidera utilizzare quello di default.\n"
|
||||
printf "E' obbligatorio specificare l'environment. In caso di environment multipli sarà utilizzato solo quello a priorità maggiore.\n"
|
||||
printf "L'opzione default di database è -f (fix).\n"
|
||||
printf "\n"
|
||||
printf "Possibili valori di option\n"
|
||||
printf "\t -h questa schermata\n"
|
||||
printf "\n"
|
||||
printf "Lista environment (per deployare la configurazione) in ordine di priorità\n"
|
||||
printf "\t -p Produzione\n"
|
||||
printf "\t -t Test\n"
|
||||
printf "\t -l Locale\n"
|
||||
printf "\n"
|
||||
printf "Opzioni database\n"
|
||||
printf "\t -D Droppa tutto il database e lo rebuilda\n"
|
||||
printf "\t -C Droppa le tabelle di contenuti e le rebuilda\n"
|
||||
printf "\t -c Droppa le tabelle di configurazione e le rebuilda\n"
|
||||
printf "\t -f Aggiunge le tabelle mancanti\n"
|
||||
printf "\t -s Skip db fix\n"
|
||||
}
|
||||
|
||||
#Stampa il nome del comando in esecuzione
|
||||
function printcmd () {
|
||||
printf "*-----------------------------------------*\n"
|
||||
printf " PROJECT: $PROJECT_NAME\n"
|
||||
printf " EXECUTING: $1\n"
|
||||
printf "\n"
|
||||
printf "*-----------------------------------------*\n"
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Imposta come proprietario della cartella l'utente apache
|
||||
function chown_folder() {
|
||||
if [[ -z "$1" ]] || [[ "$1" == "/" ]] || [[ "$1" == "./" ]]; then
|
||||
exit 1
|
||||
else
|
||||
chown -R $APACHE2_USER:$APACHE2_GROUP "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
function svncleanup() {
|
||||
if [[ -z "$1" ]] || [[ "$1" == "/" ]] || [[ "$1" == "./" ]]; then
|
||||
exit 1
|
||||
else
|
||||
for i in `find "$1" -name .svn`;
|
||||
do
|
||||
printf "Deleting .. $i\n"
|
||||
rm -rf "$i"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# Crea le cartelle di sistema
|
||||
function create_project_fs(){
|
||||
# CREATES APPLICATION PRIVATE FOLDER
|
||||
mkdir -p $APPLICATION_PRIVATE
|
||||
chown_folder $APPLICATION_PRIVATE
|
||||
|
||||
# CREATES APPLICATION PUBLIC FOLDER
|
||||
mkdir -p $APPLICATION_PUBLIC
|
||||
chown_folder $APPLICATION_PUBLIC
|
||||
|
||||
# CREATES APPLICATION STORAGE FOLDER
|
||||
mkdir -p $APPLICATION_STORAGE
|
||||
chown_folder $APPLICATION_STORAGE
|
||||
|
||||
# CREATES APPLICATION LOG FOLDER
|
||||
mkdir -p $APPLICATION_LOG_PATH
|
||||
chown_folder $APPLICATION_LOG_PATH
|
||||
|
||||
# CREATES XSENDFILE FOLDER
|
||||
mkdir -p $APPLICATION_XSENDFILE_PATH
|
||||
chown_folder $APPLICATION_XSENDFILE_PATH
|
||||
|
||||
# CREATES APPLICATION MEDIA FOLDER
|
||||
mkdir -p $APPLICATION_MEDIA_PATH
|
||||
chown_folder $APPLICATION_MEDIA_PATH
|
||||
|
||||
# CREATES APPLICATION BACKUP FOLDER
|
||||
mkdir -p $APPLICATION_BACKUPS_PATH
|
||||
chown_folder $APPLICATION_BACKUPS_PATH
|
||||
|
||||
# CREATES APPLICATION TEMPORARY FOLDER
|
||||
mkdir -p $APPLICATION_TMP_PATH
|
||||
chown_folder $APPLICATION_TMP_PATH
|
||||
}
|
||||
|
||||
|
||||
# Deploya i sorgenti
|
||||
function deploy(){
|
||||
echo "Deleting old build (Private)"
|
||||
rm -rf "$APPLICATION_PRIVATE/*"
|
||||
|
||||
echo "Deleting old build (Public)"
|
||||
rm -rf "$APPLICATION_PUBLIC/*"
|
||||
|
||||
|
||||
echo "Deploying new build (Private)"
|
||||
cp -a "./private/"* "$APPLICATION_PRIVATE"
|
||||
svncleanup "$APPLICATION_PRIVATE"
|
||||
chown_folder "$APPLICATION_PRIVATE"
|
||||
|
||||
echo "Deploying new build (Public)"
|
||||
cp -a "./public/"* "$APPLICATION_PUBLIC"
|
||||
svncleanup "$APPLICATION_PUBLIC"
|
||||
chown_folder "$APPLICATION_PUBLIC"
|
||||
|
||||
|
||||
chmod -R a+x "$APPLICATION_BINARY_PATH"
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Deploya il progetto e mantiene solo la configurazione di produzione
|
||||
function deploy_production_env(){
|
||||
create_project_fs
|
||||
deploy
|
||||
if [[ -f "$APPLICATION_CONFIG_PATH/config.local.php" ]];then
|
||||
rm "$APPLICATION_CONFIG_PATH/config.local.php"
|
||||
fi
|
||||
if [[ -f "$APPLICATION_CONFIG_PATH/config.test.php" ]];then
|
||||
rm "$APPLICATION_CONFIG_PATH/config.test.php"
|
||||
fi
|
||||
}
|
||||
|
||||
# Deploya il progetto e mantiene solo la configurazione del server di test
|
||||
function deploy_test_env(){
|
||||
create_project_fs
|
||||
deploy
|
||||
if [[ -f "$APPLICATION_CONFIG_PATH/config.local.php" ]];then
|
||||
rm "$APPLICATION_CONFIG_PATH/config.local.php"
|
||||
fi
|
||||
if [[ -f "$APPLICATION_CONFIG_PATH/config.prod.php" ]];then
|
||||
rm "$APPLICATION_CONFIG_PATH/config.prod.php"
|
||||
fi
|
||||
}
|
||||
|
||||
# Deploya il progetto e mantiene solo la configurazione locale
|
||||
function deploy_local_env(){
|
||||
create_project_fs
|
||||
deploy
|
||||
if [[ -f "$APPLICATION_CONFIG_PATH/config.local.php" ]];then
|
||||
rm "$APPLICATION_CONFIG_PATH/config.local.php"
|
||||
fi
|
||||
if [[ -f "$APPLICATION_CONFIG_PATH/config.test.php" ]];then
|
||||
rm "$APPLICATION_CONFIG_PATH/config.test.php"
|
||||
fi
|
||||
}
|
||||
|
||||
function database_rebuild_content(){
|
||||
echo "Function not implemented... faking execution"
|
||||
for collection_name in "${!MONGO_DB_CONTENT_COLLECTIONS[@]}"; do
|
||||
echo "Rebuilding collection $collection_name - ${MONGO_DB_CONTENT_COLLECTIONS["$collection_name"]}";
|
||||
done
|
||||
|
||||
for table_name in "${!MYSQL_DB_CONTENT_TABLES[@]}"; do
|
||||
echo "Rebuilding table '$table_name' using query '${MYSQL_DB_CONTENT_TABLES["$table_name"]}'";
|
||||
done
|
||||
}
|
||||
|
||||
function database_rebuild_config(){
|
||||
echo "Function not implemented... faking execution"
|
||||
for collection_name in "${!MONGO_DB_CONFIG_COLLECTIONS[@]}"; do
|
||||
echo "Rebuilding collection $collection_name - ${MONGO_DB_CONFIG_COLLECTIONS["$collection_name"]}";
|
||||
done
|
||||
|
||||
for table_name in "${!MYSQL_DB_CONFIG_TABLES[@]}"; do
|
||||
echo "Rebuilding table '$table_name' using query '${MYSQL_DB_CONFIG_TABLES["$table_name"]}'";
|
||||
done
|
||||
}
|
||||
|
||||
function database_add_missing(){
|
||||
echo "Function not implemented... faking execution"
|
||||
for collection_name in "${!MONGO_DB_CONFIG_COLLECTIONS[@]}"; do
|
||||
echo "Checking collection $collection_name - ${MONGO_DB_CONFIG_COLLECTIONS["$collection_name"]}";
|
||||
done
|
||||
|
||||
for table_name in "${!MYSQL_DB_CONFIG_TABLES[@]}"; do
|
||||
echo "Checking table '$table_name' using query '${MYSQL_DB_CONFIG_TABLES["$table_name"]}'";
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Droppa e ricrea solo le tabelle dei dati
|
||||
function regenerate_db(){
|
||||
EXDIR=`pwd`
|
||||
cd "$APPLICATION_BINARY_PATH"
|
||||
|
||||
./createDatabase
|
||||
DBCONN=`./getDbConnectionString`
|
||||
|
||||
QUERY="CREATE TABLE campagna (id bigint auto_increment PRIMARY KEY, nome VARCHAR(64), owner bigint not null, creation_date TIMESTAMP default CURRENT_TIMESTAMP, current boolean default false, deleted boolean default false)"
|
||||
TABNAME="campagna"
|
||||
EXISTS=`echo "show tables" | $DBCONN | grep "$TABNAME" | wc -l`
|
||||
if [[ "$EXISTS" -gt 0 ]];then
|
||||
echo "Dropping table $TABNAME"
|
||||
echo "DROP TABLE $TABNAME" | $DBCONN
|
||||
fi
|
||||
echo "Executing query '$QUERY'"
|
||||
echo $QUERY | $DBCONN
|
||||
|
||||
QUERY="CREATE TABLE personaggio ( id bigint auto_increment PRIMARY KEY, deleted boolean default false, campagna bigint, active boolean default true, nome varchar(128), giocatore varchar(128), vita_cur smallint, vita_max smallint, forza tinyint unsigned, destrezza tinyint unsigned, costituzione tinyint unsigned, intelligenza tinyint unsigned, saggezza tinyint unsigned, carisma tinyint unsigned, ts_tempra smallint, ts_tempra_note varchar(128), ts_riflessi smallint, ts_riflessi_note varchar(128), ts_volonta smallint, ts_volonta_note varchar(128), ca_base tinyint, ca_contatto tinyint, ca_sprovvista tinyint, iniziativa int not null default 0, ascoltare int, ascoltare_note varchar(128), cercare int, cercare_note varchar(128), diplomazia int, diplomazia_note varchar(128), muov_sil int, muov_sil_note varchar(128), nascondersi int, nascondersi_note varchar(128), osservare int, osservare_note varchar(128), perc_intenz int, perc_intenz_note varchar(128), raggirare int, raggirare_note varchar(128), valutare int, valutare_note varchar(128), conoscenze varchar(256), lingue varchar(256), melee_atk_short varchar(512), melee_atk_complete varchar(512), ranged_atk_short varchar(512), ranged_atk_complete varchar(512), unarmed_atk_short varchar(512), unarmed_atk_complete varchar(512), resist_incant smallint default 0, combat_note varchar(512), details TEXT, INDEX(campagna) )"
|
||||
TABNAME="personaggio"
|
||||
EXISTS=`echo "show tables" | $DBCONN | grep "$TABNAME" | wc -l`
|
||||
if [[ "$EXISTS" -gt 0 ]];then
|
||||
echo "Dropping table $TABNAME"
|
||||
echo "DROP TABLE $TABNAME" | $DBCONN
|
||||
fi
|
||||
echo "Executing query '$QUERY'"
|
||||
echo $QUERY | $DBCONN
|
||||
|
||||
|
||||
QUERY="CREATE TABLE npc( id bigint auto_increment PRIMARY KEY, deleted boolean default false, nome varchar(128), tipo varchar(128), dadi_vita smallint, vita_max smallint, allineamento varchar(32), grado_sfida smallint, forza tinyint unsigned, destrezza tinyint unsigned, costituzione tinyint unsigned, intelligenza tinyint unsigned, saggezza tinyint unsigned, carisma tinyint unsigned, ts_tempra smallint, ts_tempra_note varchar(128), ts_riflessi smallint, ts_riflessi_note varchar(128), ts_volonta smallint, ts_volonta_note varchar(128), ca_base tinyint, ca_contatto tinyint, ca_sprovvista tinyint, iniziativa int not null default 0, ascoltare int, ascoltare_note varchar(128), cercare int, cercare_note varchar(128), muov_sil int, muov_sil_note varchar(128), nascondersi int, nascondersi_note varchar(128), osservare int, osservare_note varchar(128), perc_intenz int, perc_intenz_note varchar(128), raggirare int, raggirare_note varchar(128), valutare int, valutare_note varchar(128), conoscenze varchar(256), lingue varchar(256), melee_atk_short varchar(512), melee_atk_complete varchar(512), ranged_atk_short varchar(512), ranged_atk_complete varchar(512), unarmed_atk_short varchar(512), unarmed_atk_complete varchar(512), resist_incant smallint default 0, combat_note varchar(512), details TEXT )"
|
||||
TABNAME="npc"
|
||||
EXISTS=`echo "show tables" | $DBCONN | grep "$TABNAME" | wc -l`
|
||||
if [[ "$EXISTS" -gt 0 ]];then
|
||||
echo "Dropping table $TABNAME"
|
||||
echo "DROP TABLE $TABNAME" | $DBCONN
|
||||
fi
|
||||
echo "Executing query '$QUERY'"
|
||||
echo $QUERY | $DBCONN
|
||||
|
||||
cd "$EXDIR"
|
||||
}
|
||||
|
||||
# Droppa e ricrea le tabelle base (tipo admin e config)
|
||||
function regenerate_db_hard(){
|
||||
EXDIR=`pwd`
|
||||
cd "$APPLICATION_BINARY_PATH"
|
||||
|
||||
./createDatabase
|
||||
DBCONN=`./getDbConnectionString`
|
||||
|
||||
|
||||
QUERY="CREATE TABLE general_configuration (config_key varchar(128) primary key, config_value varchar(128), INDEX(config_key))"
|
||||
TABNAME="general_configuration"
|
||||
EXISTS=`echo "show tables" | $DBCONN | grep "$TABNAME" | wc -l`
|
||||
if [[ "$EXISTS" -gt 0 ]];then
|
||||
echo "Dropping table $TABNAME"
|
||||
echo "DROP TABLE $TABNAME" | $DBCONN
|
||||
fi
|
||||
echo "Executing query '$QUERY'"
|
||||
echo $QUERY | $DBCONN
|
||||
|
||||
|
||||
QUERY="CREATE TABLE user (id bigint auto_increment PRIMARY KEY, login varchar(64) not null, password varchar(64) not null, last_session_id varchar(64) default null, is_admin boolean not null default false, INDEX(login), INDEX(last_session_id))"
|
||||
TABNAME="user"
|
||||
EXISTS=`echo "show tables" | $DBCONN | grep "$TABNAME" | wc -l`
|
||||
if [[ "$EXISTS" -gt 0 ]];then
|
||||
echo "Dropping table $TABNAME"
|
||||
echo "DROP TABLE $TABNAME" | $DBCONN
|
||||
fi
|
||||
echo "Executing query '$QUERY'"
|
||||
echo $QUERY | $DBCONN
|
||||
|
||||
|
||||
cd "$EXDIR"
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
content => persone => persone
|
||||
content => luoghi => luoghi
|
||||
config => configuration => the_configuration
|
||||
@@ -0,0 +1,3 @@
|
||||
content => tizi => create table tizi
|
||||
content => posti => create table posti
|
||||
config => configz => create table configz
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -z "$1" ];
|
||||
then
|
||||
echo "Missing specifier"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$1" == "5minutes" ] || [ "$1" == "minute" ] || [ "$1" == "daily" ] || [ "$1" == "hourly" ] || [ "$1" == "monthly" ] || [ "$1" == "weekly" ];
|
||||
then
|
||||
BASEDIR=`pwd`
|
||||
cd /eam/crontab/
|
||||
logger "CRONEXEC Executing $1 tasks"
|
||||
|
||||
for i in `ls | grep -P "\.$1\."`
|
||||
do
|
||||
logger "Executing $i"
|
||||
RESULT=`./$i`
|
||||
logger "$RESULT"
|
||||
done
|
||||
cd "$BASEDIR"
|
||||
else
|
||||
echo "Invalid specifier $1"
|
||||
exit 1
|
||||
fi
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
/*
|
||||
Author: Riccardo Di Dato
|
||||
Creation Date: 22/dic/2015
|
||||
*/
|
||||
|
||||
class CoreException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/*
|
||||
Author: Riccardo Di Dato
|
||||
Creation Date: 22/dic/2015
|
||||
*/
|
||||
|
||||
class GenericDao{
|
||||
private $mongo;
|
||||
|
||||
/**
|
||||
* La connection string è nel seguente formato.
|
||||
* [username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database]
|
||||
* host1 e database sono obbligatori
|
||||
*
|
||||
* @param string $connectionString
|
||||
*/
|
||||
public function __construct($name, $connectionString){
|
||||
if (!preg_match("~^\w+/\w+$~",$connectionString)){
|
||||
throw new CoreException("'GenericDao' constructed with invalid connection string '$connectionString': ");
|
||||
}
|
||||
$mongo = self::generateMongoObject($connectionString);
|
||||
}
|
||||
|
||||
public function query($collectionName, array $filter = array(), array $options = array()){
|
||||
$rval = array();
|
||||
$table = $this->getTable($name);
|
||||
|
||||
$query = new MongoDB\Driver\Query($filter, $options);
|
||||
$cursor = $this->mongo->executeQuery($collectionName,$query);
|
||||
|
||||
foreach ($cursor as $ele){
|
||||
$rval[] = new Model($ele);
|
||||
}
|
||||
return $ele;
|
||||
}
|
||||
|
||||
public function save(Model $model){
|
||||
$bulk = new MongoDB\Driver\BulkWrite(['ordered' => false]);
|
||||
$writeConcern = new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY, 1000);
|
||||
|
||||
try {
|
||||
$result = $manager->executeBulkWrite('db.collection', $bulk, $writeConcern);
|
||||
} catch (MongoDB\Driver\Exception\BulkWriteException $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function delete(Model $model){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Costruisce un oggetto mongo da passare al costruttore.
|
||||
*
|
||||
* @param string $connectionString
|
||||
* @return \MongoDB\Driver\Manager
|
||||
*/
|
||||
private static function generateMongoObject($connectionString){
|
||||
return new MongoClient("mongodb://$connectionString");
|
||||
// return new MongoDB\Driver\Manager("mongodb://$connectionString");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
/*
|
||||
Author: Riccardo Di Dato
|
||||
Creation Date: 22/dic/2015
|
||||
*/
|
||||
|
||||
class Model {
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/*
|
||||
Author: Riccardo Di Dato
|
||||
Creation Date: 14/nov/2013
|
||||
*/
|
||||
|
||||
|
||||
require_once(dirname(__FILE__)."/CoreException.php");
|
||||
|
||||
require_once(dirname(__FILE__)."/system/lib.inclusion.php");
|
||||
|
||||
|
||||
|
||||
|
||||
require_once(dirname(__FILE__)."/Status.php");
|
||||
require_once(dirname(__FILE__)."/OperationStack.php");
|
||||
require_once(dirname(__FILE__)."/OperationChain.php");
|
||||
require_once(dirname(__FILE__)."/Context.php");
|
||||
require_once(dirname(__FILE__)."/ASDSessionHandler.php");
|
||||
|
||||
require_once(dirname(__FILE__)."/CoreException.php");
|
||||
|
||||
require_once(dirname(__FILE__)."/PostHandler.php");
|
||||
|
||||
// Include Loggers
|
||||
require_once(dirname(__FILE__)."/logger/LoggingFacility.php");
|
||||
require_once(dirname(__FILE__)."/logger/LoggingFacilityManager.php");
|
||||
require_once(dirname(__FILE__)."/logger/SyslogLogger.php");
|
||||
require_once(dirname(__FILE__)."/logger/FileLogger.php");
|
||||
|
||||
// Include base UIComponents
|
||||
require_once(dirname(__FILE__)."/gui/UIComponent.php");
|
||||
require_once(dirname(__FILE__)."/gui/uicomponents/GenericUIComponent.php");
|
||||
require_once(dirname(__FILE__)."/gui/uicomponents/TextComponent.php");
|
||||
require_once(dirname(__FILE__)."/gui/uicomponents/StandardComponents.php");
|
||||
require_once(dirname(__FILE__)."/gui/uicomponents/CDataComponent.php");
|
||||
require_once(dirname(__FILE__)."/gui/uicomponents/CDataComponents.php");
|
||||
require_once(dirname(__FILE__)."/gui/uicomponents/FormComponents.php");
|
||||
require_once(dirname(__FILE__)."/gui/uicomponents/DynForm.php");
|
||||
require_once(dirname(__FILE__)."/gui/uicomponents/DynComponents.php");
|
||||
require_once(dirname(__FILE__)."/gui/uicomponents/DynTables.php");
|
||||
require_once(dirname(__FILE__)."/gui/uicomponents/unhadbComponents.php");
|
||||
|
||||
// DAO Stuff
|
||||
require_once(dirname(__FILE__)."/dao/DaoRegistry.php");
|
||||
require_once(dirname(__FILE__)."/dao/DatabaseConnection.php");
|
||||
require_once(dirname(__FILE__)."/dao/GenericDao.php");
|
||||
|
||||
require_once(dirname(__FILE__)."/dao/daos/GeneralConfigurationDao.php");
|
||||
require_once(dirname(__FILE__)."/dao/daos/AdminDao.php");
|
||||
require_once(dirname(__FILE__)."/dao/daos/ClientDao.php");
|
||||
require_once(dirname(__FILE__)."/dao/daos/BackupDao.php");
|
||||
|
||||
require_once(dirname(__FILE__)."/GeneralConfiguration.php");
|
||||
|
||||
// Include GUI Handler
|
||||
require_once(dirname(__FILE__)."/gui/GUIHandler.php");
|
||||
require_once(dirname(__FILE__)."/gui/ThumbnailGenerator.php");
|
||||
require_once(dirname(__FILE__)."/gui/CatalogManager.php");
|
||||
require_once(dirname(__FILE__)."/gui/StaticCatalogManager.php");
|
||||
|
||||
require_once(dirname(__FILE__)."/LoginManager.php");
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
/*
|
||||
Author: Riccardo Di Dato
|
||||
Creation Date: 05/mar/2015
|
||||
*/
|
||||
|
||||
Context::setContextValue("sysconfig",$config);
|
||||
ASDSessionHandler::setSessionValue("guilocale",$config->locale->gui);
|
||||
|
||||
GUIHandler::setSystemUrl($config->systemUrl);
|
||||
|
||||
GUIHandler::setCatalogManager(new StaticCatalogManager($catalog[$config->locale->gui]));
|
||||
$systemCatalogManager = new StaticCatalogManager($catalog[$config->locale->system]);
|
||||
|
||||
require_once(dirname(__FILE__)."/../common/html.include.php");
|
||||
|
||||
// // _____ ____ ___
|
||||
// // | ___/ ___| / _ \
|
||||
// // | |_ \___ \| | | |
|
||||
// // | _| ___) | |_| |
|
||||
// // |_| |____/ \___/
|
||||
// //
|
||||
// SFSManager::addFilesystem(new LocallyMountedFS(
|
||||
// FSObject::$DEVICE_TYPE_HARD_DRIVE,
|
||||
// FSObject::$WRITELAW_NOT_WRITEABLE,
|
||||
// LocallyMountedFS::$ACCESSMODE_RO,
|
||||
// "/",
|
||||
// "Root Filesystem")
|
||||
// );
|
||||
// SFSManager::addFilesystem(new LocallyMountedFS(
|
||||
// FSObject::$DEVICE_TYPE_HARD_DRIVE,
|
||||
// FSObject::$WRITELAW_NORMALLY_W,
|
||||
// LocallyMountedFS::$ACCESSMODE_RW,
|
||||
// $config->paths->log,
|
||||
// "Log Filesystem")
|
||||
// );
|
||||
// SFSManager::addFilesystem(new LocallyMountedFS(
|
||||
// FSObject::$DEVICE_TYPE_HARD_DRIVE,
|
||||
// FSObject::$WRITELAW_NORMALLY_W,
|
||||
// LocallyMountedFS::$ACCESSMODE_RW,
|
||||
// $config->paths->backup,
|
||||
// "Backups Filesystem")
|
||||
// );
|
||||
// SFSManager::addFilesystem(new LocallyMountedFS(
|
||||
// FSObject::$DEVICE_TYPE_HARD_DRIVE,
|
||||
// FSObject::$WRITELAW_NORMALLY_W,
|
||||
// LocallyMountedFS::$ACCESSMODE_RW,
|
||||
// $config->paths->media,
|
||||
// "Media Filesystem")
|
||||
// );
|
||||
// SFSManager::addFilesystem(new LocallyMountedFS(
|
||||
// FSObject::$DEVICE_TYPE_HARD_DRIVE,
|
||||
// FSObject::$WRITELAW_NORMALLY_W,
|
||||
// LocallyMountedFS::$ACCESSMODE_RW,
|
||||
// $config->paths->tmp,
|
||||
// "Temporary Filesystem")
|
||||
// );
|
||||
// SFSManager::addFilesystem(new LocallyMountedFS(
|
||||
// FSObject::$DEVICE_TYPE_HARD_DRIVE,
|
||||
// FSObject::$WRITELAW_NORMALLY_W,
|
||||
// LocallyMountedFS::$ACCESSMODE_RW,
|
||||
// $config->paths->xsendfile,
|
||||
// "XSendFile Filesystem")
|
||||
// );
|
||||
// SFSManager::addFilesystem(new LocallyMountedFS(
|
||||
// FSObject::$DEVICE_TYPE_HARD_DRIVE,
|
||||
// FSObject::$WRITELAW_NORMALLY_W,
|
||||
// LocallyMountedFS::$ACCESSMODE_RW,
|
||||
// $config->paths->pubkey,
|
||||
// "Public Keys Filesystem")
|
||||
// );
|
||||
// SFSManager::addFilesystem(new LocallyMountedFS(
|
||||
// FSObject::$DEVICE_TYPE_HARD_DRIVE,
|
||||
// FSObject::$WRITELAW_NORMALLY_W,
|
||||
// LocallyMountedFS::$ACCESSMODE_RW,
|
||||
// $config->paths->sshDir,
|
||||
// "SSH Configuration directory")
|
||||
// );
|
||||
|
||||
// // _
|
||||
// // | | ___ __ _ __ _ ___ _ __ ___
|
||||
// // | | / _ \ / _` |/ _` |/ _ \ '__/ __|
|
||||
// // | |__| (_) | (_| | (_| | __/ | \__ \
|
||||
// // |_____\___/ \__, |\__, |\___|_| |___/
|
||||
// // |___/ |___/
|
||||
// //
|
||||
// LoggingFacilityManager::addLogger(
|
||||
// "system",
|
||||
// new SyslogLogger("Core",$systemCatalogManager,true)
|
||||
// );
|
||||
// LoggingFacilityManager::getLogger("system")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG);
|
||||
|
||||
|
||||
// LoggingFacilityManager::addLogger(
|
||||
// "dao",
|
||||
// new FileLogger("DAO",$systemCatalogManager,$config->files->dao_log,true)
|
||||
// );
|
||||
// LoggingFacilityManager::getLogger("dao")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG);
|
||||
|
||||
|
||||
// LoggingFacilityManager::addLogger(
|
||||
// "saam",
|
||||
// new FileLogger("SAAM",$systemCatalogManager,$config->files->saam_log,true)
|
||||
// );
|
||||
// LoggingFacilityManager::getLogger("saam")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG);
|
||||
|
||||
|
||||
// LoggingFacilityManager::addLogger(
|
||||
// "task",
|
||||
// new FileLogger("Task",$systemCatalogManager,$config->files->task_log,true)
|
||||
// );
|
||||
// LoggingFacilityManager::getLogger("task")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG);
|
||||
|
||||
// LoggingFacilityManager::addLogger(
|
||||
// "general",
|
||||
// new FileLogger("General",$systemCatalogManager,$config->files->general_log,true)
|
||||
// );
|
||||
// LoggingFacilityManager::getLogger("general")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG);
|
||||
|
||||
|
||||
// ____ _ ___
|
||||
// | _ \ / \ / _ \
|
||||
// | | | |/ _ \| | | |
|
||||
// | |_| / ___ \ |_| |
|
||||
// |____/_/ \_\___/
|
||||
//
|
||||
new GeneralConfigurationDao($config->dbConnection);
|
||||
new AdminDao($config->dbConnection);
|
||||
new ClientDao($config->dbConnection,$config->paths->pubkey);
|
||||
new BackupDao($config->dbConnection);
|
||||
|
||||
ASDSessionHandler::regenerateContext();
|
||||
|
||||
|
||||
$checkPath = $config->paths->tmp."/backup";
|
||||
if (!file_exists($checkPath)){
|
||||
mkdir($checkPath,0751,true);
|
||||
}
|
||||
else if (!is_dir($checkPath)){
|
||||
die("Impossible to run cbs... cannot create directory '$checkPath' (a file with this name exists)");
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/*
|
||||
Author: Riccardo Di Dato
|
||||
Creation Date: 14/feb/2013
|
||||
*/
|
||||
|
||||
class FileLogger extends LoggingFacility{
|
||||
private $filePath;
|
||||
|
||||
public function __construct($name,$catalogManager,$filePath,$usedate=false) {
|
||||
$this->filePath = $filePath;
|
||||
parent::__construct($name,$catalogManager,$usedate);
|
||||
}
|
||||
|
||||
protected function writelog($level,$message,&$data) {
|
||||
// $translate_level = LOG_DEBUG;
|
||||
// if($level == LoggingFacility::$LEVEL_ERROR) $translate_level = LOG_ERROR;
|
||||
// else if($level == LoggingFacility::$LEVEL_WARNING) $translate_level = LOG_WARNING;
|
||||
// else if ($level == LoggingFacility::$LEVEL_INFO) $translate_level = LOG_INFO;
|
||||
// syslog($translate_level,$message);
|
||||
// if (!SFSManager::fileExists($this->filePath)){
|
||||
// SFSManager::touchFile($this->filePath);
|
||||
// }
|
||||
SFSManager::appendToFile($message."\n",$this->filePath);
|
||||
}
|
||||
|
||||
protected function getIndicationForLevel($level) {
|
||||
if($level == LoggingFacility::$LEVEL_ERROR) return " [ERROR] ";
|
||||
else if($level == LoggingFacility::$LEVEL_WARNING) return " [WARNING] ";
|
||||
else if ($level == LoggingFacility::$LEVEL_INFO) return " [INFO] ";
|
||||
else return " [DEBUG] ";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/*
|
||||
Author: Riccardo Di Dato
|
||||
Creation Date: 04/feb/2013
|
||||
*/
|
||||
|
||||
abstract class LoggingFacility {
|
||||
|
||||
public static $LEVEL_ERROR = 1;
|
||||
public static $LEVEL_WARNING = 2;
|
||||
public static $LEVEL_INFO = 3;
|
||||
public static $LEVEL_DEBUG = 4;
|
||||
|
||||
private $myname;
|
||||
private $useDate;
|
||||
private $mylevel;
|
||||
private $catalogManager;
|
||||
|
||||
public function __construct($name,$catalogMan,$prependDate=false) {
|
||||
$this->myname = $name;
|
||||
$this->useDate = $prependDate;
|
||||
$this->mylevel = self::$LEVEL_ERROR;
|
||||
$this->catalogManager = $catalogMan;
|
||||
}
|
||||
|
||||
|
||||
public function setLoggingLevel($level) {
|
||||
if ($level < self::$LEVEL_ERROR) $this->mylevel = self::$LEVEL_ERROR;
|
||||
else if ($level > self::$LEVEL_DEBUG) $this->mylevel = self::$LEVEL_DEBUG;
|
||||
else $this->mylevel = $level;
|
||||
}
|
||||
|
||||
|
||||
public function log($level, $message, $data = null,$usecatalog = false) {
|
||||
if($level <= $this->mylevel) {
|
||||
if(!is_array($data)) $data = array($data);
|
||||
if($usecatalog) $finalMessage = $this->catalogManager->getCatalog($message,$data);
|
||||
else $finalMessage = $message;
|
||||
if($this->useDate) {
|
||||
$formattedDate = strftime($this->catalogManager->getCatalog("core.dateformat"),time());
|
||||
$finalMessage = $this->myname . " " . $this->getIndicationForLevel($level)
|
||||
. " - " . $formattedDate . " > " . $finalMessage;
|
||||
}
|
||||
else {
|
||||
$finalMessage = $this->myname . " " . $this->getIndicationForLevel($level)
|
||||
. " > " . $finalMessage;
|
||||
}
|
||||
|
||||
$this->writelog($level,$finalMessage,$data);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract function writelog($level,$message,&$data);
|
||||
protected abstract function getIndicationForLevel($level);
|
||||
|
||||
public function getName() {
|
||||
return $this->myname;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/*
|
||||
Author: Riccardo Di Dato
|
||||
Creation Date: 04/feb/2013
|
||||
*/
|
||||
|
||||
|
||||
class LoggingFacilityManager {
|
||||
|
||||
private static $myloggers;
|
||||
|
||||
public static function addLogger($loggerName,&$loggerObject) {
|
||||
if(!isset(self::$myloggers)) self::$myloggers = array();
|
||||
self::$myloggers[$loggerName] = $loggerObject;
|
||||
}
|
||||
|
||||
public static function getLogger($loggerName) {
|
||||
if(is_array(self::$myloggers) && array_key_exists($loggerName,self::$myloggers)) {
|
||||
return self::$myloggers[$loggerName];
|
||||
}
|
||||
else throw new CoreException("Impossible to find logger '$loggerName'");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/*
|
||||
Author: Riccardo Di Dato
|
||||
Creation Date: 04/feb/2013
|
||||
*/
|
||||
|
||||
class SyslogLogger extends LoggingFacility{
|
||||
|
||||
public function __construct($name,$catalogManager,$usedate=false) {
|
||||
parent::__construct($name,$catalogManager,$usedate);
|
||||
}
|
||||
|
||||
protected function writelog($level,$message,&$data) {
|
||||
$translate_level = LOG_DEBUG;
|
||||
if($level == LoggingFacility::$LEVEL_ERROR) $translate_level = LOG_ERROR;
|
||||
else if($level == LoggingFacility::$LEVEL_WARNING) $translate_level = LOG_WARNING;
|
||||
else if ($level == LoggingFacility::$LEVEL_INFO) $translate_level = LOG_INFO;
|
||||
syslog($translate_level,$message);
|
||||
}
|
||||
|
||||
protected function getIndicationForLevel($level) {
|
||||
if($level == LoggingFacility::$LEVEL_ERROR) return " [ERROR] ";
|
||||
else if($level == LoggingFacility::$LEVEL_WARNING) return " [WARNING] ";
|
||||
else if ($level == LoggingFacility::$LEVEL_INFO) return " [INFO] ";
|
||||
else return " [DEBUG] ";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/*
|
||||
Author: Riccardo Di Dato
|
||||
Creation Date: 22/dic/2015
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__)."/LoggingFacility.php");
|
||||
require_once(dirname(__FILE__)."/LoggingFacilityManager.php");
|
||||
require_once(dirname(__FILE__)."/SyslogLogger.php");
|
||||
require_once(dirname(__FILE__)."/FileLogger.php");
|
||||
|
||||
|
||||
// _
|
||||
// | | ___ __ _ __ _ ___ _ __ ___
|
||||
// | | / _ \ / _` |/ _` |/ _ \ '__/ __|
|
||||
// | |__| (_) | (_| | (_| | __/ | \__ \
|
||||
// |_____\___/ \__, |\__, |\___|_| |___/
|
||||
// |___/ |___/
|
||||
//
|
||||
LoggingFacilityManager::addLogger(
|
||||
"system",
|
||||
new SyslogLogger("Core",$systemCatalogManager,true)
|
||||
);
|
||||
LoggingFacilityManager::getLogger("system")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG);
|
||||
|
||||
|
||||
LoggingFacilityManager::addLogger(
|
||||
"dao",
|
||||
new FileLogger("DAO",$systemCatalogManager,$config->files->dao_log,true)
|
||||
);
|
||||
LoggingFacilityManager::getLogger("dao")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG);
|
||||
|
||||
|
||||
LoggingFacilityManager::addLogger(
|
||||
"system",
|
||||
new FileLogger("SAAM",$systemCatalogManager,$config->files->saam_log,true)
|
||||
);
|
||||
LoggingFacilityManager::getLogger("saam")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG);
|
||||
|
||||
|
||||
LoggingFacilityManager::addLogger(
|
||||
"task",
|
||||
new FileLogger("Task",$systemCatalogManager,$config->files->task_log,true)
|
||||
);
|
||||
LoggingFacilityManager::getLogger("task")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG);
|
||||
|
||||
LoggingFacilityManager::addLogger(
|
||||
"general",
|
||||
new FileLogger("General",$systemCatalogManager,$config->files->general_log,true)
|
||||
);
|
||||
LoggingFacilityManager::getLogger("general")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG);
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
abstract class FSObject {
|
||||
|
||||
|
||||
public static $DEVICE_TYPE_COMPACT_FLASH = 1;
|
||||
public static $DEVICE_TYPE_HARD_DRIVE = 2;
|
||||
public static $DEVICE_TYPE_SECURE_DISK = 4;
|
||||
public static $DEVICE_TYPE_NAS = 8;
|
||||
public static $DEVICE_TYPE_OTHER_FLASH = 16;
|
||||
public static $DEVICE_TYPE_RAMFS = 32;
|
||||
|
||||
public static $WRITELAW_NORMALLY_RO = 1;
|
||||
public static $WRITELAW_NORMALLY_W = 2;
|
||||
public static $WRITELAW_NOT_WRITEABLE = 4;
|
||||
|
||||
// public static $RQ_ROOTFS = 1;
|
||||
// public static $RQ_TEMPFS = 2;
|
||||
// public static $RQ_SYSTEMSTORAGE = 4;
|
||||
// public static $RQ_USERSTORAGE = 8;
|
||||
|
||||
/**
|
||||
* Identifica la classe del dispositivo fisico che lo sostiene
|
||||
* @var int
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* Definisce le modalità di accesso al sistema
|
||||
* @var int
|
||||
*/
|
||||
public $accessMode;
|
||||
|
||||
/**
|
||||
* Identificativo di sistema del filesystem
|
||||
* @var string
|
||||
*/
|
||||
public $deviceIdentifier;
|
||||
|
||||
/**
|
||||
* Punto di mount a livello di sistema operativo
|
||||
* @var string
|
||||
*/
|
||||
public $mountPoint;
|
||||
|
||||
/**
|
||||
* Legge di scrittura (Normalmente a Sola Lettura, Normalmente Scrivibile, Non scrivibile)
|
||||
* @var int
|
||||
*/
|
||||
public $writeLaw;
|
||||
|
||||
/**
|
||||
* Qualificatore del tipo di risorsa (Filesystem di root, Filesystem di storage, Filesystem di storage utente
|
||||
* @var int
|
||||
*/
|
||||
public $resourceQualifier;
|
||||
|
||||
/**
|
||||
* Descrive il tipo di filesystem
|
||||
* @var string
|
||||
*/
|
||||
public $fstype;
|
||||
|
||||
/**
|
||||
* Nome descrittivo dello filesystem
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* Dati di connessione al file system remoto
|
||||
*/
|
||||
public $remotefsdata;
|
||||
|
||||
/**
|
||||
* Restituisce il mount point dell'FSObject
|
||||
* @return string
|
||||
*/
|
||||
public function getMountPoint(){
|
||||
return $this->mountPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrive su un file del file system in base alle sue caratteristiche
|
||||
* @param string $path
|
||||
*/
|
||||
public abstract function writeFile($content,$filePath);
|
||||
|
||||
/**
|
||||
* Scrive su un file del file system in append
|
||||
* @param string $path
|
||||
*/
|
||||
public abstract function appendToFile($content,$filePath);
|
||||
/**
|
||||
* Legge da un file del file system in base alle sue caratteristiche
|
||||
* @param string $path
|
||||
*/
|
||||
public abstract function readFile($filePath);
|
||||
|
||||
/**
|
||||
* Copia un file nella posizione inserita in base alle caratteristiche del FS
|
||||
* @param string $path
|
||||
*/
|
||||
public abstract function copyFile($source,$destination,$sudo);
|
||||
|
||||
/**
|
||||
* Sposta un file nella posizione inserita in base alle caratteristiche del FS
|
||||
* @param string $path
|
||||
*/
|
||||
public abstract function moveFile($source,$destination,$sudo);
|
||||
|
||||
/**
|
||||
* Crea un file sul file system in base alle sue caratteristiche
|
||||
* @param string $path
|
||||
*/
|
||||
public abstract function touchFile($path,$sudo);
|
||||
|
||||
/**
|
||||
* Cancella il file al percorso pecificato
|
||||
* @param string $path
|
||||
*/
|
||||
public abstract function deleteFile($path,$sudo);
|
||||
|
||||
|
||||
/**
|
||||
* Crea una cartella sul file system in base alle sue caratteristiche
|
||||
* @param string $path
|
||||
*/
|
||||
public abstract function createDirectory($path,$sudo);
|
||||
|
||||
/**
|
||||
* Copia una cartella sul file system in base alle sue caratteristiche
|
||||
* @param string $path
|
||||
*/
|
||||
public abstract function copyDirectory($source,$destination,$sudo);
|
||||
|
||||
/**
|
||||
* Verifica l'esistenza di un file
|
||||
* @param string $path
|
||||
*/
|
||||
public abstract function fileExists($filePath);
|
||||
|
||||
/**
|
||||
* Verifica l'esistenza di un file
|
||||
* @param string $path
|
||||
*/
|
||||
public abstract function directoryExists($dirPath);
|
||||
|
||||
|
||||
/**
|
||||
* Verifica che il file sia una cartella
|
||||
* @param string $path
|
||||
*/
|
||||
public abstract function isDirectory($path);
|
||||
|
||||
/**
|
||||
* Verifica che il file sia una cartella
|
||||
* @param string $path
|
||||
*/
|
||||
public abstract function lsDir($path);
|
||||
|
||||
}?>
|
||||
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SFSManager - Storage and FileSystem Manager
|
||||
* Gestore degli storage e dei filesystem presenti sul dispositivo fisico
|
||||
*
|
||||
* @author Riccardo Di Dato
|
||||
*
|
||||
*/
|
||||
|
||||
class SFSException extends CoreException {}
|
||||
|
||||
class SFSManager {
|
||||
|
||||
private static $fslist;
|
||||
|
||||
|
||||
public static function getFilesystemList() {
|
||||
if(self::$fslist == null || !is_array(self::$fslist) || sizeof(self::$fslist)==0) return null;
|
||||
return self::$fslist;
|
||||
}
|
||||
|
||||
public static function addFilesystem($fsobj) {
|
||||
if (!($fsobj instanceof FSObject)) throw new SFSException("sfs.man.notafso");
|
||||
if(self::$fslist == null || !is_array(self::$fslist)) self::$fslist = array();
|
||||
|
||||
self::$fslist[]=$fsobj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function getFSObjByPath($path){
|
||||
$memory=null;
|
||||
foreach (self::$fslist as $fso){
|
||||
if (preg_match('|^'.$fso->getMountPoint().'|',$path)){
|
||||
if ($memory!=null){
|
||||
if (preg_match('|^'.$memory->getMountPoint().'|',$fso->getMountPoint())){
|
||||
$memory=$fso;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$memory=$fso;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $memory;
|
||||
}
|
||||
|
||||
public static function readFile($path){
|
||||
$fso=self::getFSObjByPath($path);
|
||||
if($fso!=null){
|
||||
return $fso->readFile($path);
|
||||
}
|
||||
}
|
||||
|
||||
public static function writeFile($content,$file){
|
||||
$fso=self::getFSObjByPath($file);
|
||||
if($fso!=null){
|
||||
return $fso->writeFile($content,$file);
|
||||
}
|
||||
}
|
||||
|
||||
public static function appendToFile($content,$file){
|
||||
$fso=self::getFSObjByPath($file);
|
||||
if($fso!=null){
|
||||
return $fso->appendToFile($content,$file);
|
||||
}
|
||||
}
|
||||
|
||||
public static function copyFile($source,$destination,$sudo=false){
|
||||
$fso=self::getFSObjByPath($destination);
|
||||
if($fso!=null){
|
||||
return $fso->copyFile($source,$destination,$sudo);
|
||||
}
|
||||
}
|
||||
|
||||
public static function moveFile($source,$destination,$sudo=false){
|
||||
$fso=self::getFSObjByPath($destination);
|
||||
if($fso!=null){
|
||||
return $fso->moveFile($source,$destination,$sudo);
|
||||
}
|
||||
}
|
||||
|
||||
public static function touchFile($path,$sudo=false){
|
||||
$fso=self::getFSObjByPath($path);
|
||||
if($fso!=null){
|
||||
return $fso->touchFile($path,$sudo);
|
||||
}
|
||||
}
|
||||
|
||||
public static function deleteFile($path,$sudo=false){
|
||||
$fso=self::getFSObjByPath($path);
|
||||
if($fso!=null){
|
||||
return $fso->deleteFile($path,$sudo);
|
||||
}
|
||||
}
|
||||
|
||||
public static function createDirectory($path,$sudo=false){
|
||||
$fso=self::getFSObjByPath($path);
|
||||
if($fso!=null){
|
||||
return $fso->createDirectory($path,$sudo);
|
||||
}
|
||||
}
|
||||
|
||||
public static function copyDirectory($source,$destination,$sudo=false){
|
||||
$fso=self::getFSObjByPath($destination);
|
||||
if($fso!=null){
|
||||
return $fso->copyDirectory($source,$destination,$sudo);
|
||||
}
|
||||
}
|
||||
|
||||
public static function fileExists($path){
|
||||
$fso=self::getFSObjByPath($path);
|
||||
if($fso!=null){
|
||||
return $fso->fileExists($path);
|
||||
}
|
||||
}
|
||||
|
||||
public static function lsDir($path){
|
||||
$fso=self::getFSObjByPath($path);
|
||||
if($fso!=null){
|
||||
return $fso->lsDir($path);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
class SystemException extends CoreException{}
|
||||
|
||||
class SystemController {
|
||||
|
||||
private static function logMessage($level,$message,$data=null) {
|
||||
LoggingFacilityManager::getLogger("saam")->log($level,$message,$data,true);
|
||||
}
|
||||
|
||||
public static function shellExec($cmdName,$cmdParams="",$sudo=false){
|
||||
$myCmd=($sudo?"sudo ":"").$cmdName.($cmdParams!=""?" ".$cmdParams:"");
|
||||
|
||||
self::logMessage(LoggingFacility::$LEVEL_DEBUG,"log.sysctl.tryexecute",$myCmd." 2>&1");
|
||||
|
||||
$answers=array();
|
||||
$execReturn=null;
|
||||
exec($myCmd." 2>&1",$answers,$execReturn);
|
||||
$return=new SystemAnswer($execReturn,$answers);
|
||||
if ($return->status!=0){
|
||||
if ( is_array($return->messages) && sizeof($return->messages)>0 ){
|
||||
foreach ($return->messages as $answer){
|
||||
self::logMessage(LoggingFacility::$LEVEL_DEBUG,$answer);
|
||||
}
|
||||
}
|
||||
self::logMessage(LoggingFacility::$LEVEL_ERROR,"log.sysctl.cantexecute",$myCmd." 2>&1",true);
|
||||
$catParameters=array($myCmd,$return->messages[sizeof($return->messages)-1],$return);
|
||||
throw new SystemException("exc.sysctl.cantexecute",$catParameters);
|
||||
}
|
||||
|
||||
self::logMessage(LoggingFacility::$LEVEL_INFO,"log.sysctl.correctlyexecute",$myCmd." 2>&1",true);
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function executeCustomCommand($cmdName,$cmdParams="",$sudo=false){
|
||||
$binpath = Context::getContextValue("sysconfig")->application->custom_bin_path;
|
||||
return self::shellExec($binpath."/".$cmdName,$cmdParams,$sudo);
|
||||
}
|
||||
|
||||
public static function executeTask($cmdName,$cmdParams="",$sudo=false){
|
||||
$basePath = Context::getContextValue("sysconfig")->application->tasks_path;
|
||||
return self::shellExec($basePath."/".$cmdName,$cmdParams,$sudo);
|
||||
}
|
||||
|
||||
public static function mountRo($path) {
|
||||
return self::executeCustomCommand("mountro",'"'.$path.'"');
|
||||
}
|
||||
|
||||
public static function mountRw($path) {
|
||||
return self::executeCustomCommand("mountrw",'"'.$path.'"');
|
||||
}
|
||||
|
||||
public static function cp($source,$dest,$useSudo=false){
|
||||
return self::shellExec("cp",'"'.$source.'" "'.$dest.'"',$useSudo);
|
||||
}
|
||||
|
||||
public static function cpRec($source,$dest,$useSudo=false){
|
||||
return self::shellExec("cp",'-r "'.$source.'" "'.$dest.'"',$useSudo);
|
||||
}
|
||||
|
||||
public static function mv($source,$dest,$useSudo=false){
|
||||
return self::shellExec("mv",'"'.$source.'" "'.$dest.'"',$useSudo);
|
||||
}
|
||||
|
||||
public static function touch($path,$useSudo=false){
|
||||
return self::shellExec("touch",'"'.$path.'"',$useSudo);
|
||||
}
|
||||
|
||||
public static function mkdir($path,$useSudo=false){
|
||||
return self::shellExec("mkdir",'"'.$path.'"',$useSudo);
|
||||
}
|
||||
|
||||
public static function rm($path,$useSudo=false){
|
||||
return self::shellExec("rm",'"'.$path.'"',$useSudo);
|
||||
}
|
||||
|
||||
public static function wget($targetPage,$destFile,$useSudo=false){
|
||||
return self::shellExec("wget",'-O "'.$destFile.'" '.$targetPage,$useSudo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SystemAnswer {
|
||||
public $status;
|
||||
public $messages;
|
||||
|
||||
public function __construct($status,$messages){
|
||||
$this->status=$status;
|
||||
$this->messages=$messages;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
class LocallyMountedFS extends FSObject {
|
||||
public static $ACCESSMODE_RO = 1;
|
||||
public static $ACCESSMODE_RW = 2;
|
||||
|
||||
private $sys;
|
||||
private $catalog;
|
||||
|
||||
public function __construct($deviceType, $writelaw,$accessmode,$mountPoint,$name){
|
||||
|
||||
$this->type=$deviceType;
|
||||
$this->writeLaw=$writelaw;
|
||||
$this->accessMode=$accessmode;
|
||||
$this->mountPoint=$mountPoint;
|
||||
|
||||
$this->name=$name;
|
||||
}
|
||||
|
||||
private function useSysFunction($funcName){
|
||||
$funcArgs = array();
|
||||
for ($i = 1; $i < func_num_args(); $i++){
|
||||
$funcArgs[] = func_get_arg($i);
|
||||
}
|
||||
if ($this->accessMode==self::$ACCESSMODE_RW){
|
||||
if ($this->writeLaw==parent::$WRITELAW_NOT_WRITEABLE){
|
||||
throw new SFSException('fsobj.not_writeable',$this->name);
|
||||
}
|
||||
else if ($this->writeLaw==parent::$WRITELAW_NORMALLY_RO){
|
||||
SystemController::mountRw($this->mountPoint);
|
||||
call_user_func_array(array("SystemController",$funcName),$funcArgs);
|
||||
SystemController::mountRw($this->mountPoint);
|
||||
}
|
||||
else if ($this->writeLaw==parent::$WRITELAW_NORMALLY_W){
|
||||
call_user_func_array(array("SystemController",$funcName),$funcArgs);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new SFSException('fsobj.not_writeable',$this->name);
|
||||
}
|
||||
}
|
||||
|
||||
private function write($content,$file,$mode='w'){
|
||||
$fh = fopen($file, $mode);
|
||||
if ($fh === false){
|
||||
throw new SFSException('fsobj.file_not_writeable',$file);
|
||||
}
|
||||
$count = 0;
|
||||
$done = false;
|
||||
while (!$done && $count<3){
|
||||
if (flock($fh, LOCK_EX)){
|
||||
fwrite($fh,$content);
|
||||
// flock($fh, LOCK_UN); // not necessary
|
||||
$done = true;
|
||||
}
|
||||
else {
|
||||
sleep(5);
|
||||
}
|
||||
$count++;
|
||||
}
|
||||
fclose($fh);
|
||||
if (!$done){
|
||||
throw new SFSException("Error writing file '$file'... the file is being used from another resource.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function readFile($path){
|
||||
// var_dump($path);
|
||||
$fh = fopen($path, 'r');
|
||||
if ($fh === false){
|
||||
throw new SFSException('fsobj.file_not_readable',$path);
|
||||
}
|
||||
$done = false;
|
||||
$count = 0;
|
||||
while (!$done && $count<3){
|
||||
if (flock($fh, LOCK_EX)){
|
||||
$rows=file($path);
|
||||
$done = true;
|
||||
}
|
||||
else {
|
||||
sleep(5);
|
||||
}
|
||||
$count++;
|
||||
}
|
||||
fclose($fh);
|
||||
if (!$done){
|
||||
throw new SFSException("Error reading file '$path'... the file is being used from another resource.");
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public function appendToFile($content,$file){
|
||||
if ($this->accessMode==self::$ACCESSMODE_RO || $this->writeLaw==parent::$WRITELAW_NOT_WRITEABLE){
|
||||
throw new SFSException('fsobj.not_writeable',$this->name);
|
||||
}
|
||||
else if ($this->writeLaw==parent::$WRITELAW_NORMALLY_W) {
|
||||
$this->write($content,$file,'a');
|
||||
}
|
||||
else if ($this->writeLaw==parent::$WRITELAW_NORMALLY_RO) {
|
||||
SystemController::mountRw($this->mountPoint);
|
||||
$this->write($content,$file,'a');
|
||||
SystemController::mountRw($this->mountPoint);
|
||||
}
|
||||
}
|
||||
|
||||
public function writeFile($content,$file){
|
||||
if ($this->accessMode==self::$ACCESSMODE_RO || $this->writeLaw==parent::$WRITELAW_NOT_WRITEABLE){
|
||||
throw new SFSException('fsobj.not_writeable',$this->name);
|
||||
}
|
||||
else if ($this->writeLaw==parent::$WRITELAW_NORMALLY_W) {
|
||||
$this->write($content,$file);
|
||||
}
|
||||
else if ($this->writeLaw==parent::$WRITELAW_NORMALLY_RO) {
|
||||
SystemController::mountRw($this->mountPoint);
|
||||
$this->write($content,$file);
|
||||
SystemController::mountRw($this->mountPoint);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function moveFile($source,$destination,$useSudo=false){
|
||||
$this->useSysFunction("mv",$source,$destination,$useSudo);
|
||||
}
|
||||
|
||||
public function copyFile($source,$destination,$useSudo=false){
|
||||
$this->useSysFunction("cp",$source,$destination,$useSudo);
|
||||
}
|
||||
|
||||
public function touchFile($path,$useSudo=false){
|
||||
$this->useSysFunction("touch",$path,$useSudo);
|
||||
}
|
||||
|
||||
public function deleteFile($path,$useSudo=false){
|
||||
$this->useSysFunction("rm",$path,$useSudo);
|
||||
}
|
||||
|
||||
public function createDirectory($path,$useSudo=false){
|
||||
$this->useSysFunction("mkdir",$path,$useSudo);
|
||||
}
|
||||
|
||||
public function copyDirectory($source,$destination,$useSudo=false){
|
||||
$this->useSysFunction("cpRec",$source,$destination,$useSudo);
|
||||
}
|
||||
|
||||
public function fileExists($path){
|
||||
return (file_exists($path));
|
||||
}
|
||||
|
||||
public function directoryExists($path){
|
||||
return (file_exists($path));
|
||||
}
|
||||
|
||||
public function isDirectory($path){
|
||||
return ($this->directoryExists($path) && is_dir($path));
|
||||
}
|
||||
|
||||
public function lsDir($path){
|
||||
$rval = array();
|
||||
if ($this->isDirectory($path)){
|
||||
if ($dh = opendir($path)) {
|
||||
while (($file = readdir($dh)) !== false) {
|
||||
if (strcmp($file,".")!=0 && strcmp($file,"..")!=0){
|
||||
$rval[] = $file;
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
}
|
||||
return $rval;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/*
|
||||
Author: Riccardo Di Dato
|
||||
Creation Date: 22/dic/2015
|
||||
*/
|
||||
|
||||
|
||||
// Inclue Saam
|
||||
require_once(dirname(__FILE__)."/FSObject.php");
|
||||
require_once(dirname(__FILE__)."/SFSManager.php");
|
||||
require_once(dirname(__FILE__)."/SystemController.php");
|
||||
|
||||
require_once(dirname(__FILE__)."/fsobjects/LocallyMountedFS.php");
|
||||
|
||||
// _____ ____ ___
|
||||
// | ___/ ___| / _ \
|
||||
// | |_ \___ \| | | |
|
||||
// | _| ___) | |_| |
|
||||
// |_| |____/ \___/
|
||||
//
|
||||
SFSManager::addFilesystem(new LocallyMountedFS(
|
||||
FSObject::$DEVICE_TYPE_HARD_DRIVE,
|
||||
FSObject::$WRITELAW_NOT_WRITEABLE,
|
||||
LocallyMountedFS::$ACCESSMODE_RO,
|
||||
"/",
|
||||
"Root Filesystem")
|
||||
);
|
||||
SFSManager::addFilesystem(new LocallyMountedFS(
|
||||
FSObject::$DEVICE_TYPE_HARD_DRIVE,
|
||||
FSObject::$WRITELAW_NORMALLY_W,
|
||||
LocallyMountedFS::$ACCESSMODE_RW,
|
||||
$config->paths->log,
|
||||
"Log Filesystem")
|
||||
);
|
||||
SFSManager::addFilesystem(new LocallyMountedFS(
|
||||
FSObject::$DEVICE_TYPE_HARD_DRIVE,
|
||||
FSObject::$WRITELAW_NORMALLY_W,
|
||||
LocallyMountedFS::$ACCESSMODE_RW,
|
||||
$config->paths->backup,
|
||||
"Backups Filesystem")
|
||||
);
|
||||
SFSManager::addFilesystem(new LocallyMountedFS(
|
||||
FSObject::$DEVICE_TYPE_HARD_DRIVE,
|
||||
FSObject::$WRITELAW_NORMALLY_W,
|
||||
LocallyMountedFS::$ACCESSMODE_RW,
|
||||
$config->paths->media,
|
||||
"Media Filesystem")
|
||||
);
|
||||
SFSManager::addFilesystem(new LocallyMountedFS(
|
||||
FSObject::$DEVICE_TYPE_HARD_DRIVE,
|
||||
FSObject::$WRITELAW_NORMALLY_W,
|
||||
LocallyMountedFS::$ACCESSMODE_RW,
|
||||
$config->paths->tmp,
|
||||
"Temporary Filesystem")
|
||||
);
|
||||
SFSManager::addFilesystem(new LocallyMountedFS(
|
||||
FSObject::$DEVICE_TYPE_HARD_DRIVE,
|
||||
FSObject::$WRITELAW_NORMALLY_W,
|
||||
LocallyMountedFS::$ACCESSMODE_RW,
|
||||
$config->paths->xsendfile,
|
||||
"XSendFile Filesystem")
|
||||
);
|
||||
SFSManager::addFilesystem(new LocallyMountedFS(
|
||||
FSObject::$DEVICE_TYPE_HARD_DRIVE,
|
||||
FSObject::$WRITELAW_NORMALLY_W,
|
||||
LocallyMountedFS::$ACCESSMODE_RW,
|
||||
$config->paths->pubkey,
|
||||
"Public Keys Filesystem")
|
||||
);
|
||||
SFSManager::addFilesystem(new LocallyMountedFS(
|
||||
FSObject::$DEVICE_TYPE_HARD_DRIVE,
|
||||
FSObject::$WRITELAW_NORMALLY_W,
|
||||
LocallyMountedFS::$ACCESSMODE_RW,
|
||||
$config->paths->sshDir,
|
||||
"SSH Configuration directory")
|
||||
);
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
/*
|
||||
Author: Riccardo Di Dato
|
||||
Creation Date: 22/dic/2015
|
||||
*/
|
||||
|
||||
echo "Index";
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user