mirror of
https://github.com/YunoHost-Apps/jirafeau_ynh.git
synced 2024-09-03 19:35:53 +02:00
upload_password & admin ynh user in place of simple admin password
This commit is contained in:
parent
6a032ab5fd
commit
7faecf9ce1
5 changed files with 50 additions and 4 deletions
|
@ -35,7 +35,8 @@ $cfg['lang'] = 'auto';
|
||||||
$cfg['style'] = 'modern';
|
$cfg['style'] = 'modern';
|
||||||
$cfg['rewrite'] = false;
|
$cfg['rewrite'] = false;
|
||||||
/* An empty admin password will disable the admin interface. */
|
/* An empty admin password will disable the admin interface. */
|
||||||
$cfg['admin_password'] = 'test';
|
$cfg['admin_password'] = '';
|
||||||
|
$cfg['admin_user'] = 'YNH_ADMIN_USER';
|
||||||
/* preview: false (will download file) or true (will preview in browser if
|
/* preview: false (will download file) or true (will preview in browser if
|
||||||
* possible) . */
|
* possible) . */
|
||||||
$cfg['preview'] = false;
|
$cfg['preview'] = false;
|
||||||
|
@ -53,7 +54,7 @@ $cfg['enable_crypt'] = false;
|
||||||
/* Split lenght of link refenrece. */
|
/* Split lenght of link refenrece. */
|
||||||
$cfg['link_name_lenght'] = 8;
|
$cfg['link_name_lenght'] = 8;
|
||||||
/* Upload password. Empty string disable the password. */
|
/* Upload password. Empty string disable the password. */
|
||||||
$cfg['upload_password'] = '';
|
$cfg['upload_password'] = 'YNH_UPLOAD_PASSWORD';
|
||||||
|
|
||||||
if ((basename (__FILE__) != 'config.local.php')
|
if ((basename (__FILE__) != 'config.local.php')
|
||||||
&& file_exists (JIRAFEAU_ROOT.'lib/config.local.php'))
|
&& file_exists (JIRAFEAU_ROOT.'lib/config.local.php'))
|
||||||
|
|
3
conf/user_list.py
Normal file
3
conf/user_list.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
import sys, json
|
||||||
|
userlist=json.loads(sys.stdin.readlines()[0])["Users"]
|
||||||
|
print "{0}".format("\n".join(i["Username"] for i in userlist))
|
|
@ -27,6 +27,20 @@
|
||||||
"example": "/jirafeau",
|
"example": "/jirafeau",
|
||||||
"default": "/jirafeau"
|
"default": "/jirafeau"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "admin_user",
|
||||||
|
"ask": {
|
||||||
|
"en": "Choose an admin user (will be able to access admin.php page)"
|
||||||
|
},
|
||||||
|
"example": "johndoe"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "upload_password",
|
||||||
|
"ask": {
|
||||||
|
"en": "Set the password granting upload permissions (leave empty to allow anybody to upload)"
|
||||||
|
},
|
||||||
|
"example": "supersecretpassword"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "is_public",
|
"name": "is_public",
|
||||||
"ask": {
|
"ask": {
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
domain=$1
|
domain=$1
|
||||||
path=$2
|
path=$2
|
||||||
is_public=$3
|
admin_user=$3
|
||||||
|
upload_password=$4
|
||||||
|
is_public=$5
|
||||||
|
|
||||||
# Check domain/path availability
|
# Check domain/path availability
|
||||||
sudo yunohost app checkurl $domain$path -a jirafeau
|
sudo yunohost app checkurl $domain$path -a jirafeau
|
||||||
|
@ -11,6 +13,13 @@ if [[ ! $? -eq 0 ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Chack that admin user is an existing account
|
||||||
|
sudo yunohost user list | python ../conf/user_list.py | grep "^$admin_user$"
|
||||||
|
if [[ ! $? -eq 0 ]]; then
|
||||||
|
echo "Error : the chosen admin user does not exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
final_path=/var/www/jirafeau
|
final_path=/var/www/jirafeau
|
||||||
var_root=/home/yunohost.app/jirafeau
|
var_root=/home/yunohost.app/jirafeau
|
||||||
|
|
||||||
|
@ -20,6 +29,8 @@ sudo cp -r ../sources/* $final_path
|
||||||
sed -i "s@YNH_DOMAIN@$domain@g" ../conf/config.local.php
|
sed -i "s@YNH_DOMAIN@$domain@g" ../conf/config.local.php
|
||||||
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/config.local.php
|
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/config.local.php
|
||||||
sed -i "s@YNH_VAR_ROOT@$var_root@g" ../conf/config.local.php
|
sed -i "s@YNH_VAR_ROOT@$var_root@g" ../conf/config.local.php
|
||||||
|
sed -i "s@YNH_ADMIN_USER@$admin_user@g" ../conf/config.local.php
|
||||||
|
sed -i "s@YNH_UPLOAD_PASSWORD@$upload_password@g" ../conf/config.local.php
|
||||||
sudo cp ../conf/config.local.php $final_path/lib
|
sudo cp ../conf/config.local.php $final_path/lib
|
||||||
sudo rm $final_path/install.php
|
sudo rm $final_path/install.php
|
||||||
|
|
||||||
|
@ -53,7 +64,7 @@ sudo chmod 644 $finalphpini
|
||||||
|
|
||||||
if [ $is_public = "Yes" ];
|
if [ $is_public = "Yes" ];
|
||||||
then
|
then
|
||||||
sudo yunohost app setting jirafeau skipped_uris -v "/"
|
sudo yunohost app setting jirafeau unprotected_uris -v "/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo service php5-fpm restart
|
sudo service php5-fpm restart
|
||||||
|
|
|
@ -43,7 +43,14 @@ if (file_exists (JIRAFEAU_ROOT . 'install.php'))
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$cfg['admin_user'] || $_SERVER['PHP_AUTH_USER'] != $cfg['admin_user'])
|
||||||
|
{
|
||||||
|
header('Location: index.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
/* Disable admin interface if we have a empty admin password. */
|
/* Disable admin interface if we have a empty admin password. */
|
||||||
|
/*
|
||||||
if (!$cfg['admin_password'])
|
if (!$cfg['admin_password'])
|
||||||
{
|
{
|
||||||
require (JIRAFEAU_ROOT . 'lib/template/header.php');
|
require (JIRAFEAU_ROOT . 'lib/template/header.php');
|
||||||
|
@ -53,15 +60,21 @@ if (!$cfg['admin_password'])
|
||||||
require (JIRAFEAU_ROOT.'lib/template/footer.php');
|
require (JIRAFEAU_ROOT.'lib/template/footer.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/* Check session. */
|
/* Check session. */
|
||||||
|
/*
|
||||||
session_start();
|
session_start();
|
||||||
|
*/
|
||||||
|
|
||||||
/* Unlog if asked. */
|
/* Unlog if asked. */
|
||||||
|
/*
|
||||||
if (isset ($_POST['action']) && (strcmp ($_POST['action'], 'logout') == 0))
|
if (isset ($_POST['action']) && (strcmp ($_POST['action'], 'logout') == 0))
|
||||||
$_SESSION['admin_auth'] = false;
|
$_SESSION['admin_auth'] = false;
|
||||||
|
*/
|
||||||
|
|
||||||
/* Check password. */
|
/* Check password. */
|
||||||
|
/*
|
||||||
if (isset ($_POST['admin_password']))
|
if (isset ($_POST['admin_password']))
|
||||||
{
|
{
|
||||||
if (strcmp ($cfg['admin_password'], $_POST['admin_password']) == 0)
|
if (strcmp ($cfg['admin_password'], $_POST['admin_password']) == 0)
|
||||||
|
@ -76,7 +89,10 @@ if (isset ($_POST['admin_password']))
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/* Ask for password. */
|
/* Ask for password. */
|
||||||
|
/*
|
||||||
elseif (!isset ($_SESSION['admin_auth']) || $_SESSION['admin_auth'] != true)
|
elseif (!isset ($_SESSION['admin_auth']) || $_SESSION['admin_auth'] != true)
|
||||||
{
|
{
|
||||||
require (JIRAFEAU_ROOT . 'lib/template/header.php'); ?>
|
require (JIRAFEAU_ROOT . 'lib/template/header.php'); ?>
|
||||||
|
@ -106,6 +122,7 @@ elseif (!isset ($_SESSION['admin_auth']) || $_SESSION['admin_auth'] != true)
|
||||||
require (JIRAFEAU_ROOT.'lib/template/footer.php');
|
require (JIRAFEAU_ROOT.'lib/template/footer.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/* Operations may take a long time.
|
/* Operations may take a long time.
|
||||||
* Be sure PHP's safe mode is off.
|
* Be sure PHP's safe mode is off.
|
||||||
|
|
Loading…
Reference in a new issue