mirror of
https://github.com/YunoHost-Apps/shaarli_ynh.git
synced 2024-09-03 20:26:10 +02:00
working installation
This commit is contained in:
parent
0cf59c2135
commit
83294ef5c7
7 changed files with 100 additions and 61 deletions
|
@ -1,16 +1,4 @@
|
|||
<?php
|
||||
$GLOBALS['login'] = array (
|
||||
YNH_LOGINS
|
||||
);
|
||||
$GLOBALS['password'] = array (
|
||||
YNH_PASSWORDS
|
||||
);
|
||||
$GLOBALS['level'] = array (
|
||||
YNH_LEVELS
|
||||
);
|
||||
$GLOBALS['email'] = array (
|
||||
YNH_EMAILS
|
||||
);
|
||||
$GLOBALS['salt'] = 'YNH_SALT';
|
||||
$GLOBALS['timezone'] = 'YNH_TIMEZONE';
|
||||
date_default_timezone_set('YNH_TIMEZONE');
|
||||
|
@ -18,5 +6,8 @@ $GLOBALS['title'] = 'YNH_TITLE';
|
|||
$GLOBALS['redirector'] = '';
|
||||
$GLOBALS['disablesessionprotection'] = false;
|
||||
$GLOBALS['disablejquery'] = false;
|
||||
$GLOBALS['privateLinkByDefault'] = YNH_PRIVATE_LINK_BY_DEFAULT;
|
||||
$GLOBALS['privateLinkByDefault'] = 'YNH_PRIVATE_LINK_BY_DEFAULT';
|
||||
$GLOBALS['ynh_admin'] = 'YNH_ADMIN';
|
||||
|
||||
require(realpath(dirname(__FILE__)) . '/config_user.php');
|
||||
?>
|
17
conf/init_config.php
Normal file
17
conf/init_config.php
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
$GLOBALS['salt'] = 'YNH_SALT';
|
||||
$GLOBALS['timezone'] = 'YNH_TIMEZONE';
|
||||
date_default_timezone_set('YNH_TIMEZONE');
|
||||
$GLOBALS['title'] = 'YNH_TITLE';
|
||||
$GLOBALS['redirector'] = '';
|
||||
$GLOBALS['disablesessionprotection'] = false;
|
||||
$GLOBALS['disablejquery'] = false;
|
||||
$GLOBALS['privateLinkByDefault'] = YNH_PRIVATE_LINK_BY_DEFAULT;
|
||||
$GLOBALS['ynh_admin'] = 'YNH_ADMIN';
|
||||
|
||||
$userconfigfile = realpath(dirname(__FILE__)) . '/config_user.php';
|
||||
if (is_file($userconfigfile))
|
||||
{
|
||||
require($userconfigfile);
|
||||
}
|
||||
?>
|
52
conf/init_config_user.php
Normal file
52
conf/init_config_user.php
Normal file
|
@ -0,0 +1,52 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
require('/home/yunohost.app/shaarli/data/config.php');
|
||||
|
||||
$userlist=$argv;
|
||||
array_shift($userlist);
|
||||
|
||||
foreach($userlist as $usercount => $userlogin)
|
||||
{
|
||||
$userlevel = '2';
|
||||
if ($userlogin == $GLOBALS['ynh_admin'])
|
||||
{
|
||||
$userlevel = '4';
|
||||
}
|
||||
|
||||
$currentLogin = array($userlogin);
|
||||
$currentPassword = array($userlogin => '');
|
||||
$currentLevel = array($userlogin => $userlevel);
|
||||
$currentEmail = array($userlogin => '');
|
||||
|
||||
if (array_key_exists('login', $GLOBALS))
|
||||
{
|
||||
$GLOBALS['login'] = array_merge($GLOBALS['login'], $currentLogin);
|
||||
$GLOBALS['password'] = array_merge($GLOBALS['password'], $currentPassword);
|
||||
$GLOBALS['level'] = array_merge($GLOBALS['level'], $currentLevel);
|
||||
$GLOBALS['email'] = array_merge($GLOBALS['email'], $currentEmail);
|
||||
}
|
||||
else
|
||||
{
|
||||
$GLOBALS['login'] = $currentLogin;
|
||||
$GLOBALS['password'] = $currentPassword;
|
||||
$GLOBALS['level'] = $currentLevel;
|
||||
$GLOBALS['email'] = $currentEmail;
|
||||
}
|
||||
}
|
||||
|
||||
$userconf = '<?php' . PHP_EOL;
|
||||
$userconf .= '$GLOBALS[\'login\'] = ' . var_export($GLOBALS['login'],true) . ';' . PHP_EOL;
|
||||
$userconf .= '$GLOBALS[\'password\'] = ' . var_export($GLOBALS['password'],true) . ';' . PHP_EOL;
|
||||
$userconf .= '$GLOBALS[\'level\'] = ' . var_export($GLOBALS['level'],true) . ';' . PHP_EOL;
|
||||
$userconf .= '$GLOBALS[\'email\'] = ' . var_export($GLOBALS['email'],true) . ';' . PHP_EOL;
|
||||
$userconf .= '?>';
|
||||
|
||||
$userconf_file = '/home/yunohost.app/shaarli/data/config_user.php';
|
||||
if (!file_put_contents($userconf_file, $userconf) || strcmp(file_get_contents($userconf_file),$userconf)!=0)
|
||||
{
|
||||
fwrite(STDERR, "Error while writing " . $userconf_file);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
?>
|
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))
|
|
@ -51,6 +51,14 @@
|
|||
},
|
||||
"choices": ["Yes", "No"],
|
||||
"default": "Yes"
|
||||
},
|
||||
{
|
||||
"name": "admin",
|
||||
"ask": {
|
||||
"en": "Admin user"
|
||||
},
|
||||
"example": "test",
|
||||
"default": "test"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ path=$2
|
|||
is_public=$3
|
||||
title=$4
|
||||
privatelinkbydefault=$5
|
||||
admin=$6
|
||||
|
||||
|
||||
# Check domain/path availability
|
||||
|
@ -27,58 +28,28 @@ do
|
|||
done
|
||||
|
||||
salt=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p')
|
||||
if [ $privatelinkbydefault = "No" ]; then
|
||||
privatelinkbydefault_php=false
|
||||
else
|
||||
privatelinkbydefault_php=true
|
||||
fi
|
||||
|
||||
user_count=0
|
||||
for user in $(sudo yunohost user list | python user_list.py)
|
||||
do
|
||||
if [[ ! $user == yunohost.* ]];
|
||||
then
|
||||
|
||||
YNH_LOGINS=$(cat << EOF
|
||||
$YNH_LOGINS\\
|
||||
$user_count => $user,
|
||||
EOF
|
||||
)
|
||||
sudo sed -i "s@YNH_SALT@$salt@g" ../conf/init_config.php
|
||||
sudo sed -i "s@YNH_TIMEZONE@$(cat /etc/timezone)@g" ../conf/init_config.php
|
||||
sudo sed -i "s@YNH_TITLE@$title@g" ../conf/init_config.php
|
||||
sudo sed -i "s@YNH_PRIVATE_LINK_BY_DEFAULT@$privatelinkbydefault_php@g" ../conf/init_config.php
|
||||
sudo sed -i "s@YNH_ADMIN@$admin@g" ../conf/init_config.php
|
||||
|
||||
YNH_PASSWORDS=$(cat << EOF
|
||||
$YNH_PASSWORDS\\
|
||||
$user => '',
|
||||
EOF
|
||||
)
|
||||
|
||||
YNH_LEVELS=$(cat << EOF
|
||||
$YNH_LEVELS\\
|
||||
$user => 2,
|
||||
EOF
|
||||
)
|
||||
|
||||
YNH_EMAILS=$(cat << EOF
|
||||
$YNH_EMAILS\\
|
||||
$user => ''
|
||||
EOF
|
||||
)
|
||||
|
||||
let user_count++
|
||||
fi
|
||||
done
|
||||
|
||||
sudo sed -i "s@YNH_LOGINS@$YNH_LOGINS@g" ../conf/config.php
|
||||
sudo sed -i "s@YNH_PASSWORDS@$YNH_PASSWORDS@g" ../conf/config.php
|
||||
sudo sed -i "s@YNH_LEVELS@$YNH_LEVELS@g" ../conf/config.php
|
||||
sudo sed -i "s@YNH_EMAILS@$YNH_EMAILS@g" ../conf/config.php
|
||||
sudo sed -i "s@YNH_SALT@$salt@g" ../conf/config.php
|
||||
sudo sed -i "s@YNH_TIMEZONE@$(cat /etc/timezone)@g" ../conf/config.php
|
||||
sudo sed -i "s@YNH_TITLE@$title@g" ../conf/config.php
|
||||
sudo sed -i "s@YNH_PRIVATE_LINK_BY_DEFAULT@$privatelinkbydefault@g" ../conf/config.php
|
||||
|
||||
sudo cp ../conf/config.php $app_home_path/data
|
||||
sudo cp ../conf/options.php $app_home_path/data/options.php
|
||||
sudo cp ../conf/init_config.php $app_home_path/data/config.php
|
||||
sudo php ../conf/init_config_user.php $(sudo yunohost user list | python ../conf/user_list.py)
|
||||
|
||||
sudo find $final_path -type f | xargs sudo chmod 644
|
||||
sudo find $final_path -type d | xargs sudo chmod 755
|
||||
sudo chown -R root: $final_path
|
||||
|
||||
sudo find $app_home_path -type f | xargs sudo chmod 640
|
||||
sudo find $app_home_path -type d | xargs sudo chmod 750
|
||||
sudo find $app_home_path -type f | xargs sudo chmod 600
|
||||
sudo find $app_home_path -type d | xargs sudo chmod 700
|
||||
sudo chown -R www-data: $app_home_path
|
||||
|
||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
import sys, json
|
||||
for user in json.loads(sys.stdin.readlines()[0])["Users"]:
|
||||
print user["Username"]
|
Loading…
Add table
Reference in a new issue