Merge pull request #4630 from MrPetovan/task/4629-move-executable-to-bin
Move executable scripts to bin/ (part 1)
This commit is contained in:
commit
4d8d5ca6a5
17 changed files with 37 additions and 37 deletions
66
bin/auth_ejabberd.php
Normal file
66
bin/auth_ejabberd.php
Normal file
|
@ -0,0 +1,66 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
/*
|
||||
* ejabberd extauth script for the integration with friendica
|
||||
*
|
||||
* Originally written for joomla by Dalibor Karlovic <dado@krizevci.info>
|
||||
* modified for Friendica by Michael Vogel <icarus@dabo.de>
|
||||
* published under GPL
|
||||
*
|
||||
* Latest version of the original script for joomla is available at:
|
||||
* http://87.230.15.86/~dado/ejabberd/joomla-login
|
||||
*
|
||||
* Installation:
|
||||
*
|
||||
* - Change it's owner to whichever user is running the server, ie. ejabberd
|
||||
* $ chown ejabberd:ejabberd /path/to/friendica/bin/auth_ejabberd.php
|
||||
*
|
||||
* - Change the access mode so it is readable only to the user ejabberd and has exec
|
||||
* $ chmod 700 /path/to/friendica/bin/auth_ejabberd.php
|
||||
*
|
||||
* - Edit your ejabberd.cfg file, comment out your auth_method and add:
|
||||
* {auth_method, external}.
|
||||
* {extauth_program, "/path/to/friendica/bin/auth_ejabberd.php"}.
|
||||
*
|
||||
* - Restart your ejabberd service, you should be able to login with your friendica auth info
|
||||
*
|
||||
* Other hints:
|
||||
* - if your users have a space or a @ in their nickname, they'll run into trouble
|
||||
* registering with any client so they should be instructed to replace these chars
|
||||
* " " (space) is replaced with "%20"
|
||||
* "@" is replaced with "(a)"
|
||||
*
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Util\ExAuth;
|
||||
|
||||
if (sizeof($_SERVER["argv"]) == 0) {
|
||||
die();
|
||||
}
|
||||
|
||||
$directory = dirname($_SERVER["argv"][0]);
|
||||
|
||||
if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR) {
|
||||
$directory = $_SERVER["PWD"] . DIRECTORY_SEPARATOR . $directory;
|
||||
}
|
||||
|
||||
$directory = realpath($directory . DIRECTORY_SEPARATOR . "..");
|
||||
|
||||
chdir($directory);
|
||||
|
||||
require_once "boot.php";
|
||||
require_once "include/dba.php";
|
||||
|
||||
$a = new App(dirname(__DIR__));
|
||||
BaseObject::setApp($a);
|
||||
|
||||
@include ".htconfig.php";
|
||||
dba::connect($db_host, $db_user, $db_pass, $db_data);
|
||||
unset($db_host, $db_user, $db_pass, $db_data);
|
||||
|
||||
$oAuth = new ExAuth();
|
||||
|
||||
$oAuth->readStdin();
|
BIN
bin/composer.phar
Normal file
BIN
bin/composer.phar
Normal file
Binary file not shown.
126
bin/daemon.php
Normal file
126
bin/daemon.php
Normal file
|
@ -0,0 +1,126 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
/**
|
||||
* @file bin/daemon.php
|
||||
* @brief Run the worker from a daemon.
|
||||
*
|
||||
* This script was taken from http://php.net/manual/en/function.pcntl-fork.php
|
||||
*/
|
||||
function shutdown() {
|
||||
posix_kill(posix_getpid(), SIGHUP);
|
||||
}
|
||||
|
||||
if (in_array("start", $_SERVER["argv"])) {
|
||||
$mode = "start";
|
||||
}
|
||||
|
||||
if (in_array("stop", $_SERVER["argv"])) {
|
||||
$mode = "stop";
|
||||
}
|
||||
|
||||
if (in_array("status", $_SERVER["argv"])) {
|
||||
$mode = "status";
|
||||
}
|
||||
|
||||
if (!isset($mode)) {
|
||||
die("Please use either 'start', 'stop' or 'status'.\n");
|
||||
}
|
||||
|
||||
if (empty($_SERVER["argv"][0])) {
|
||||
die("Unexpected script behaviour. This message should never occur.\n");
|
||||
}
|
||||
|
||||
// Fetch the base directory
|
||||
$directory = dirname($_SERVER["argv"][0]);
|
||||
|
||||
if (substr($directory, 0, 1) != "/") {
|
||||
$directory = $_SERVER["PWD"]."/".$directory;
|
||||
}
|
||||
$directory = realpath($directory."/..");
|
||||
|
||||
@include($directory."/.htconfig.php");
|
||||
|
||||
if (!isset($pidfile)) {
|
||||
die('Please specify a pid file in the variable $pidfile in the .htconfig.php. For example:'."\n".
|
||||
'$pidfile = "/path/to/daemon.pid";'."\n");
|
||||
}
|
||||
|
||||
if (in_array($mode, array("stop", "status"))) {
|
||||
$pid = @file_get_contents($pidfile);
|
||||
|
||||
if (!$pid) {
|
||||
die("Pidfile wasn't found. Is the daemon running?\n");
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode == "status") {
|
||||
if (posix_kill($pid, 0)) {
|
||||
die("Daemon process $pid is running.\n");
|
||||
}
|
||||
|
||||
unlink($pidfile);
|
||||
|
||||
die("Daemon process $pid isn't running.\n");
|
||||
}
|
||||
|
||||
if ($mode == "stop") {
|
||||
posix_kill($pid, SIGTERM);
|
||||
|
||||
unlink($pidfile);
|
||||
|
||||
die("Worker daemon process $pid was killed.\n");
|
||||
}
|
||||
|
||||
echo "Starting worker daemon.\n";
|
||||
|
||||
if (isset($a->config['php_path'])) {
|
||||
$php = $a->config['php_path'];
|
||||
} else {
|
||||
$php = "php";
|
||||
}
|
||||
|
||||
// Switch over to daemon mode.
|
||||
if ($pid = pcntl_fork())
|
||||
return; // Parent
|
||||
|
||||
fclose(STDIN); // Close all of the standard
|
||||
fclose(STDOUT); // file descriptors as we
|
||||
fclose(STDERR); // are running as a daemon.
|
||||
|
||||
register_shutdown_function('shutdown');
|
||||
|
||||
if (posix_setsid() < 0)
|
||||
return;
|
||||
|
||||
if ($pid = pcntl_fork())
|
||||
return; // Parent
|
||||
|
||||
$pid = getmypid();
|
||||
file_put_contents($pidfile, $pid);
|
||||
|
||||
// Now running as a daemon.
|
||||
while (true) {
|
||||
// Just to be sure that this script really runs endlessly
|
||||
set_time_limit(0);
|
||||
|
||||
// Call the worker
|
||||
$cmdline = $php.' bin/worker.php';
|
||||
|
||||
$executed = false;
|
||||
|
||||
if (function_exists('proc_open')) {
|
||||
$resource = proc_open($cmdline . ' &', array(), $foo, $directory);
|
||||
|
||||
if (is_resource($resource)) {
|
||||
$executed = true;
|
||||
proc_close($resource);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$executed) {
|
||||
exec($cmdline.' spawn');
|
||||
}
|
||||
|
||||
// Now sleep for 5 minutes
|
||||
sleep(300);
|
||||
}
|
101
bin/run_xgettext.sh
Normal file
101
bin/run_xgettext.sh
Normal file
|
@ -0,0 +1,101 @@
|
|||
#!/bin/bash
|
||||
FULLPATH=$(dirname $(readlink -f "$0"))
|
||||
|
||||
if [ "$1" == "--help" -o "$1" == "-h" ]
|
||||
then
|
||||
echo "$(basename $(readlink -f "$0")) [options]"
|
||||
echo
|
||||
echo "-a | --addon <name> extract strings from addon 'name'"
|
||||
echo "-s | --single single addon mode: extract string from current folder"
|
||||
exit
|
||||
fi
|
||||
|
||||
MODE='default'
|
||||
ADDONNAME=
|
||||
if [ "$1" == "--addon" -o "$1" == "-a" ]
|
||||
then
|
||||
MODE='addon'
|
||||
if [ -z $2 ]; then echo -e "ERROR: missing addon name\n\nrun_xgettext.sh -a <addonname>"; exit 1; fi
|
||||
ADDONNAME=$2
|
||||
if [ ! -d "$FULLPATH/../addon/$ADDONNAME" ]; then echo "ERROR: addon '$ADDONNAME' not found"; exit 2; fi
|
||||
fi
|
||||
|
||||
if [ "$1" == "--single" -o "$1" == "-s" ]
|
||||
then
|
||||
MODE='single'
|
||||
fi
|
||||
|
||||
|
||||
case "$MODE" in
|
||||
'addon')
|
||||
cd "$FULLPATH/../addon/$ADDONNAME"
|
||||
mkdir -p "$FULLPATH/../addon/$ADDONNAME/lang/C"
|
||||
OUTFILE="$FULLPATH/../addon/$ADDONNAME/lang/C/messages.po"
|
||||
FINDSTARTDIR="."
|
||||
FINDOPTS=
|
||||
;;
|
||||
'single')
|
||||
FULLPATH=$PWD
|
||||
ADDONNAME=$(basename $FULLPATH)
|
||||
mkdir -p "$FULLPATH/lang/C"
|
||||
OUTFILE="$FULLPATH/lang/C/messages.po"
|
||||
FINDSTARTDIR="."
|
||||
FINDOPTS=
|
||||
echo "Extract strings for single addon '$ADDONNAME'"
|
||||
;;
|
||||
'default')
|
||||
cd "$FULLPATH/.."
|
||||
OUTFILE="$FULLPATH/messages.po"
|
||||
FINDSTARTDIR="."
|
||||
# skip addon folder
|
||||
FINDOPTS="( -wholename */addon -or -wholename */addons-extra -or -wholename */smarty3 ) -prune -o"
|
||||
|
||||
F9KVERSION=$(sed -n "s/.*'FRIENDICA_VERSION'.*'\([0-9.]*\)'.*/\1/p" ./boot.php);
|
||||
echo "Friendica version $F9KVERSION"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
KEYWORDS="-k -kt -ktt:1,2"
|
||||
|
||||
echo "extract strings to $OUTFILE.."
|
||||
rm "$OUTFILE"; touch "$OUTFILE"
|
||||
for f in $(find "$FINDSTARTDIR" $FINDOPTS -name "*.php" -type f)
|
||||
do
|
||||
if [ ! -d "$f" ]
|
||||
then
|
||||
xgettext $KEYWORDS -j -o "$OUTFILE" --from-code=UTF-8 "$f"
|
||||
sed -i "s/CHARSET/UTF-8/g" "$OUTFILE"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "setup base info.."
|
||||
case "$MODE" in
|
||||
'addon'|'single')
|
||||
sed -i "s/SOME DESCRIPTIVE TITLE./ADDON $ADDONNAME/g" "$OUTFILE"
|
||||
sed -i "s/YEAR THE PACKAGE'S COPYRIGHT HOLDER//g" "$OUTFILE"
|
||||
sed -i "s/FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.//g" "$OUTFILE"
|
||||
sed -i "s/PACKAGE VERSION//g" "$OUTFILE"
|
||||
sed -i "s/PACKAGE/Friendica $ADDONNAME addon/g" "$OUTFILE"
|
||||
sed -i "s/CHARSET/UTF-8/g" "$OUTFILE"
|
||||
sed -i "s/^\"Plural-Forms.*$//g" "$OUTFILE"
|
||||
;;
|
||||
'default')
|
||||
sed -i "s/SOME DESCRIPTIVE TITLE./FRIENDICA Distributed Social Network/g" "$OUTFILE"
|
||||
sed -i "s/YEAR THE PACKAGE'S COPYRIGHT HOLDER/2010, 2011, 2012, 2013 the Friendica Project/g" "$OUTFILE"
|
||||
sed -i "s/FIRST AUTHOR <EMAIL@ADDRESS>, YEAR./Mike Macgirvin, 2010/g" "$OUTFILE"
|
||||
sed -i "s/PACKAGE VERSION/$F9KVERSION/g" "$OUTFILE"
|
||||
sed -i "s/PACKAGE/Friendica/g" "$OUTFILE"
|
||||
sed -i "s/CHARSET/UTF-8/g" "$OUTFILE"
|
||||
sed -i "s/^\"Plural-Forms.*$//g" "$OUTFILE"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "" != "$1" -a "$MODE" == "default" ]
|
||||
then
|
||||
UPDATEFILE="$(readlink -f ${FULLPATH}/$1)"
|
||||
echo "merging new strings to $UPDATEFILE.."
|
||||
msgmerge -U $OUTFILE $UPDATEFILE
|
||||
fi
|
||||
|
||||
echo "done."
|
66
bin/worker.php
Normal file
66
bin/worker.php
Normal file
|
@ -0,0 +1,66 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
/**
|
||||
* @file bin/worker.php
|
||||
* @brief Starts the background processing
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Worker;
|
||||
|
||||
// Ensure that worker.php is executed from the base path of the installation
|
||||
if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
|
||||
$directory = dirname($_SERVER["argv"][0]);
|
||||
|
||||
if (substr($directory, 0, 1) != "/") {
|
||||
$directory = $_SERVER["PWD"]."/".$directory;
|
||||
}
|
||||
$directory = realpath($directory."/..");
|
||||
|
||||
chdir($directory);
|
||||
}
|
||||
|
||||
require_once "boot.php";
|
||||
require_once "include/dba.php";
|
||||
|
||||
$a = new App(dirname(__DIR__));
|
||||
BaseObject::setApp($a);
|
||||
|
||||
require_once ".htconfig.php";
|
||||
dba::connect($db_host, $db_user, $db_pass, $db_data);
|
||||
unset($db_host, $db_user, $db_pass, $db_data);
|
||||
|
||||
Config::load();
|
||||
|
||||
// Check the database structure and possibly fixes it
|
||||
check_db(true);
|
||||
|
||||
// Quit when in maintenance
|
||||
if (Config::get('system', 'maintenance', true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$a->set_baseurl(Config::get('system', 'url'));
|
||||
|
||||
Addon::loadHooks();
|
||||
|
||||
$spawn = (($_SERVER["argc"] == 2) && ($_SERVER["argv"][1] == "spawn"));
|
||||
|
||||
if ($spawn) {
|
||||
Worker::spawnWorker();
|
||||
killme();
|
||||
}
|
||||
|
||||
$run_cron = (($_SERVER["argc"] <= 1) || ($_SERVER["argv"][1] != "no_cron"));
|
||||
|
||||
Worker::processQueue($run_cron);
|
||||
|
||||
Worker::unclaimProcess();
|
||||
|
||||
Worker::endProcess();
|
||||
|
||||
killme();
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue