mirror of
https://github.com/YunoHost-Apps/yourls_ynh.git
synced 2024-09-03 20:35:59 +02:00
Merge pull request #1 from julienmalik/master
better auth, full-automatic install
This commit is contained in:
commit
74af6dfa10
5 changed files with 46 additions and 16 deletions
3
conf/activate_plugins.sql
Normal file
3
conf/activate_plugins.sql
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
INSERT INTO `yourls_options` ( `option_name`, `option_value`) VALUES
|
||||||
|
('active_plugins', 'a:1:{i:0;s:24:"yunohost_auth/plugin.php";}');
|
||||||
|
|
|
@ -57,7 +57,6 @@ define( 'YOURLS_COOKIEKEY', 'modify this text with something random' );
|
||||||
** YOURLS will auto encrypt plain text passwords in this file
|
** YOURLS will auto encrypt plain text passwords in this file
|
||||||
** Read http://yourls.org/userpassword for more information */
|
** Read http://yourls.org/userpassword for more information */
|
||||||
$yourls_user_passwords = array(
|
$yourls_user_passwords = array(
|
||||||
'yourlsuser' => 'yourlspass' // You can have one or more 'login'=>'password' lines
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/** Debug mode to output some internal information
|
/** Debug mode to output some internal information
|
||||||
|
@ -88,3 +87,5 @@ $yourls_reserved_URL = array(
|
||||||
** Personal settings would go after here.
|
** Personal settings would go after here.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
define( 'YOURLS_YUNOHOST_AUTH_ADMIN', 'yourlsuser' );
|
||||||
|
|
||||||
|
|
21
conf/yunohost_auth/plugin.php
Normal file
21
conf/yunohost_auth/plugin.php
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
Plugin Name: YunoHost Auth plugin
|
||||||
|
Plugin URI: http://yourls.org/
|
||||||
|
Description: Authentification plugin for YunoHost
|
||||||
|
Version: 0.1
|
||||||
|
Author: ju
|
||||||
|
Author URI: http://github.com/julienmalik
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct call
|
||||||
|
if( !defined( 'YOURLS_ABSPATH' ) ) die();
|
||||||
|
|
||||||
|
yourls_add_filter( 'shunt_is_valid_user', 'yunohost_auth_is_valid_user' );
|
||||||
|
|
||||||
|
function yunohost_auth_is_valid_user( $value ) {
|
||||||
|
return $_SERVER['PHP_AUTH_USER'] == YOURLS_YUNOHOST_AUTH_ADMIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* And that's it. Activate the plugin and notice how the page title changes */
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
"name": "Yourls",
|
"name": "Yourls",
|
||||||
"id": "yourls",
|
"id": "yourls",
|
||||||
"description": {
|
"description": {
|
||||||
"en": "a URL shortening service",
|
"en": "An URL shortening service",
|
||||||
"fr": "un service de raccourcisseur d'url"
|
"fr": "Un service de raccourcisseur d'url"
|
||||||
},
|
},
|
||||||
"developer": {
|
"developer": {
|
||||||
"name": "courgette",
|
"name": "courgette",
|
||||||
|
@ -34,17 +34,9 @@
|
||||||
"name": "admin",
|
"name": "admin",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Choose the Yourls administrator (must be an existing YunoHost user)",
|
"en": "Choose the Yourls administrator (must be an existing YunoHost user)",
|
||||||
"fr": "Administrateur du site (doit être un utilisateur Yunohost existant)"
|
"fr": "Administrateur du site Yourls (doit être un utilisateur Yunohost existant)"
|
||||||
},
|
},
|
||||||
"example": "yoda"
|
"example": "yoda"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "upload_password",
|
|
||||||
"ask": {
|
|
||||||
"en": "Set the password granting upload permissions (leave empty to allow anybody to upload)",
|
|
||||||
"fr": "Choisissez le password pour autoriser l'upload (laissez vide pour autorisé tout le monde)"
|
|
||||||
},
|
|
||||||
"example": "supersecretpassword"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
domain=$1
|
domain=$1
|
||||||
path=$2
|
path=$2
|
||||||
admin_user=$3
|
admin_user=$3
|
||||||
upload_password=$4
|
|
||||||
|
|
||||||
# Check domain/path availability
|
# Check domain/path availability
|
||||||
sudo yunohost app checkurl $domain$path -a yourls
|
sudo yunohost app checkurl $domain$path -a yourls
|
||||||
|
@ -36,6 +35,8 @@ sudo mkdir -p $final_path
|
||||||
sudo cp -a ../sources/* $final_path
|
sudo cp -a ../sources/* $final_path
|
||||||
|
|
||||||
sudo cp ../conf/index.php $final_path/
|
sudo cp ../conf/index.php $final_path/
|
||||||
|
sudo cp -r ../conf/yunohost_auth $final_path/user/plugins
|
||||||
|
|
||||||
|
|
||||||
# Change variable in yourls configuration
|
# Change variable in yourls configuration
|
||||||
sudo cp ../conf/config.php $final_path/user/config.php
|
sudo cp ../conf/config.php $final_path/user/config.php
|
||||||
|
@ -44,10 +45,8 @@ sudo sed -i "s/yunopass/$db_pwd/g" $final_path/user/config.php
|
||||||
sudo sed -i "s/yunobase/$db_user/g" $final_path/user/config.php
|
sudo sed -i "s/yunobase/$db_user/g" $final_path/user/config.php
|
||||||
sudo sed -i "s/yunodomain/$domain/g" $final_path/user/config.php
|
sudo sed -i "s/yunodomain/$domain/g" $final_path/user/config.php
|
||||||
sudo sed -i "s/yourlsuser/$admin_user/g" $final_path/user/config.php
|
sudo sed -i "s/yourlsuser/$admin_user/g" $final_path/user/config.php
|
||||||
sudo sed -i "s/yourlspass/$upload_password/g" $final_path/user/config.php
|
|
||||||
sudo sed -i "s/_yourlspath$path/g" $final_path/user/config.php
|
sudo sed -i "s/_yourlspath$path/g" $final_path/user/config.php
|
||||||
|
|
||||||
|
|
||||||
# Set permissions
|
# Set permissions
|
||||||
sudo chown -R www-data: $final_path
|
sudo chown -R www-data: $final_path
|
||||||
|
|
||||||
|
@ -62,4 +61,18 @@ sudo chmod 600 $nginxconf
|
||||||
|
|
||||||
# Reload Nginx and regenerate SSOwat conf
|
# Reload Nginx and regenerate SSOwat conf
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
|
sudo yunohost app setting yourls unprotected_uris -v "/"
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
|
||||||
|
# Start Yourls install (database table creation)
|
||||||
|
curl -kL -X POST https://$domain$path/admin/install.php --data "install=dummy" > /dev/null 2>&1
|
||||||
|
|
||||||
|
# Activate auth plugin
|
||||||
|
mysql -u $db_user -p$db_pwd $db_user < ../conf/activate_plugins.sql
|
||||||
|
|
||||||
|
#sudo yunohost app setting yourls skipped_uris -d
|
||||||
|
#sudo yunohost app setting yourls unprotected_uris -v "/admin"
|
||||||
|
|
||||||
|
sudo service nginx reload
|
||||||
|
sudo yunohost app ssowatconf
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue