added script for adding of user to zotero

modified install_zotero.sh to include the newly added_script
master
Patrick Höhn 2014-10-30 15:59:38 +01:00
parent 1440f927e8
commit fb19bcb1ff
2 changed files with 54 additions and 1 deletions

50
add_user Normal file
View File

@ -0,0 +1,50 @@
#!/usr/bin/php
<?
set_include_path("../include");
require("header.inc.php");
if (empty($argv[1]) || empty($argv[2]) || empty($argv[3]) || empty($argv[4])) {
die("Usage: $argv[0] " . '$userID $email $username $real_user_name' . "\n");
}
$username = $argv[1];
$email = $argv[2];
$password = $argv[3];
$real_user = $argv[4];
echo "Adding new user $username\n";
$passwordhash = password_hash($password);
$libraryID = Zotero_Libraries::add('user', 1);
Zotero_DB::beginTransaction();
$sql = "INSERT INTO zotero_www.users (username, password) VALUES (?,?)";
Zotero_DB::query($sql, array( $username,$passwordhash));
$sql = "SELECT userID FROM zotero_www.users WHERE username=?";
$userID = Zotero_DB:valueQuery($sql, $username);
$sql = "INSERT INTO zotero_master.users (userID, libraryID, username) VALUES (?,?)";
Zotero_DB::query($sql, array($userID, $libraryID, $username));
$sql = "INSERT INTO zotero_master.storageAccounts (userID, quota, expiration) VALUES (?,?,?);";
Zotero_DB::query($sql,array($userID, '10000', '2020-12-31 00:00:00'));
$sql = "INSERT INTO zotero_www.user_email (userID, email) VALUES (?,?);";
Zotero_DB::query($sql,array($userID, $email));
$sql = "INSERT INTO zotero_www.LUM_User (RoleID, UserID) VALUES (3,?);";
Zotero_DB::query($sql,array($userID));
$sql = "INSERT INTO zotero_www.users_meta (userID, metaKey, metaValue) VALUES (?,'profile_realname',?);";
Zotero_DB::query($sql,array($userID,$real_user));
Zotero_DB::commit();
?>

View File

@ -16,7 +16,7 @@ echo "update package cache"
apt-get update
echo "dependencies for dataserver"
apt-get install -y apache2 libapache2-mod-php5 mysql-server memcached zendframework php5-cli php5-memcache php5-mysql php5-curl
apt-get install -y apache2 libapache2-mod-php5 mysql-server memcached zendframework php5-cli php5-memcache php5-mysql php5-curl php5-memcached
echo "general dependencies"
apt-get install -y git gnutls-bin runit libapache2-modsecurity curl
@ -40,6 +40,9 @@ git clone git://github.com/ruflin/Elastica.git /srv/zotero/dataserver/include/El
cd /srv/zotero/dataserver/include/Elastica
git checkout fc607170ab2ca751097648d48a5d38e15e9d5f6a
echo "install add_user script"
cp add_user /srv/zotero/dataserver/admin
echo "install composer"
cd /srv/zotero/dataserver
curl -sS https://getcomposer.org/installer | php