1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/hubzilla_ynh.git synced 2024-09-03 19:26:21 +02:00
This commit is contained in:
Andrew Manning 2015-08-23 11:33:13 -04:00
commit c67d330eea
11 changed files with 248 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.DS_Store

22
README.md Normal file
View file

@ -0,0 +1,22 @@
# YunoHost App for Hubzilla Hub #
Notes
--------------
Before installing, read the [Red Matrix installation instructions](https://github.com/redmatrix/redmatrix/blob/master/install/INSTALL.txt) for important information about
- SSL certificate validation requirement
- Dedicated domain (must install under web root like **https://red.example.com/** not **https://example.com/red/** )
- Required packages (these are not yet installed by this YunoHost installer package)
Red Matrix
--------------
Current snapshot in *sources*:
* core: 37d07a7d2a3808169b87c5033ef413ce957bf2ef)
* redmatrix-addons: 8364a6a628be16286a3569f713652a43c87e37e3
**Red Matrix will be re-branded as [Hubzilla](https://github.com/redmatrix/hubzilla) as part of a major release coming soon.**

32
conf/nginx.conf Normal file
View file

@ -0,0 +1,32 @@
location YNH_WWW_PATH {
# Path to source
alias YNH_WWW_ALIAS/ ;
# Force https
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
# Example PHP configuration
index index.php index.html;
try_files $uri $uri/ index.php;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
# .htaccess file from Hubzilla converted using http://winginx.com/en/htaccess
location ~ "(^|/)\.git" { return 403; }
location ~ "(^|/)store" { return 403; }
autoindex off;
location / { if (!-e $request_filename){ rewrite ^(.*)$ /index.php?q=$1; } }
location ~ \.(out|log|gz)$ { deny all; }
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}

2
conf/poller-cron Normal file
View file

@ -0,0 +1,2 @@
# Run poller periodically to update Hubzilla
*/10 * * * * cd YNH_WWW_PATH; php include/poller.php

47
manifest.json Normal file
View file

@ -0,0 +1,47 @@
{
"name": "Hubzilla",
"id": "hubzilla",
"description": {
"en": "Hubzilla is a decentralized publication platform and social network."
},
"licence": "CopyLeft",
"developer": {
"name": "Mike Macgirvin",
"email": "",
"url": "https://github.com/redmatrix/hubzilla"
},
"multi_instance": "false",
"arguments": {
"install" : [
{
"name": "domain",
"ask": {
"en": "Choose a domain for your Hubzilla hub. Hubzilla must run in the root of this domain."
},
"example": "hub.example.com"
},
{
"name": "admin",
"ask": {
"en": "Choose an admin user"
},
"example": "johndoe"
},
{
"name": "adminemail",
"ask": {
"en": "Email address for the Hubzilla hub admin"
},
"example": "johndoe@example.com"
},
{
"name": "is_public",
"ask": {
"en": "Is it a public application ?"
},
"choices": ["Yes", "No"],
"default": "Yes"
}
]
}
}

2
scripts/addpoller Normal file
View file

@ -0,0 +1,2 @@
final_path=$1
(crontab -l ; echo "*/10 * * * * cd $final_path; php include/poller.php") 2>&1 | grep -v "no crontab" | sort | uniq | crontab -

77
scripts/install Executable file
View file

@ -0,0 +1,77 @@
#!/bin/bash
app=hubzilla
# Retrieve arguments
domain=$1
admin=$2
adminemail=$3
is_public=$4
path="/"
# Save app settings
sudo yunohost app setting $app admin -v "$admin"
sudo yunohost app setting $app is_public -v "$is_public"
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a "$app"
if [[ ! $? -eq 0 ]]; then
exit 1
fi
# Install dependencies
sudo apt-get install -y -qq php5-cli php5-imagick php5-gd php5-mcrypt
# Generate random password
db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p')
# Use 'hubzilla' as database name and user
db_user=$app
# Initialize database and store mysql password for upgrade
sudo yunohost app initdb $db_user -p $db_pwd
sudo yunohost app setting $app mysqlpwd -v $db_pwd
# Copy source files
final_path=/var/www/$app
sudo mkdir -p $final_path
sudo rsync -va ../sources/ $final_path/
sudo mkdir -p "$final_path/store/[data]/smarty3"
sudo chmod -R 777 $final_path/store
# Import database schema
sudo mysql -u $db_user -p$db_pwd $db_user < $final_path/install/schema_mysql.sql
# Copy the template install/htconfig.sample.php to .htconfig.php
sudo cp $final_path/install/htconfig.sample.php $final_path/.htconfig.php
# Use sed to add the database information to .htconfig.php
sudo sed -i "s/your.mysqlhost.com/localhost/g" $final_path/.htconfig.php
sudo sed -i "s/mysqlpassword/$db_pwd/g" $final_path/.htconfig.php
sudo sed -i "s/mysqlusername/$db_user/g" $final_path/.htconfig.php
sudo sed -i "s/mysqldatabasename/$db_user/g" $final_path/.htconfig.php
sudo sed -i "s/myredsite.example/$domain/g" $final_path/.htconfig.php
sudo sed -i "s/[\'admin_email\'] = \'\';/[\'admin_email\'] = \'$adminemail\';/g" $final_path/.htconfig.php
sudo sed -i "s/if the auto install failed, put a unique random string here/$db_pwd$db_pwd$db_pwd/g" $final_path/.htconfig.php
# Set www-data to owner
sudo chown -R www-data: $final_path
# Set up poller
sed -i "s@YNH_WWW_PATH@$final_path@g" ../conf/poller-cron
sudo cp ../conf/poller-cron /etc/cron.d/poller-cron
# Modify Nginx configuration file and copy it to Nginx conf directory
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
# If app is public, add url to SSOWat conf as skipped_uris
if [ "$is_public" = "Yes" ];
then
sudo yunohost app setting $app skipped_uris -v "/"
fi
# Restart services
sudo service nginx reload
sudo yunohost app ssowatconf

27
scripts/remove Executable file
View file

@ -0,0 +1,27 @@
#!/bin/bash
app=hubzilla
# Retrieve arguments
domain=$(sudo yunohost app setting $app domain)
path=$(sudo yunohost app setting $app path)
admin=$(sudo yunohost app setting $app admin)
is_public=$(sudo yunohost app setting $app is_public)
db_user=$app
db_name=$app
root_pwd=$(sudo cat /etc/yunohost/mysql)
domain=$(sudo yunohost app setting $app domain)
mysql -u root -p$root_pwd -e "DROP DATABASE $db_name ; DROP USER $db_user@localhost ;"
# Remove sources
sudo rm -rf /var/www/$app
# Remove configuration files
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
# Remove poller cron job
sudo rm -f /etc/cron.d/poller-cron
# Restart services
sudo service nginx reload
sudo yunohost app ssowatconf

2
scripts/removepoller Normal file
View file

@ -0,0 +1,2 @@
final_path=$1
(crontab -l ; echo "*/10 * * * * cd $final_path; php include/poller.php") 2>&1 | grep -v "no crontab" | grep -v "include/poller.php" | sort | uniq | crontab -

35
scripts/upgrade Executable file
View file

@ -0,0 +1,35 @@
#!/bin/bash
app=hubzilla
# Retrieve arguments
domain=$(sudo yunohost app setting $app domain)
path=$(sudo yunohost app setting $app path)
admin=$(sudo yunohost app setting $app admin)
is_public=$(sudo yunohost app setting $app is_public)
# Remove trailing "/" for next commands
path=${path%/}
# Copy source files
final_path=/var/www/$app
sudo mkdir -p $final_path
sudo rsync -va ../sources/ $final_path/
# Set www-data to owner
sudo chown -R www-data: $final_path
# Modify Nginx configuration file and copy it to Nginx conf directory
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
# If app is public, add url to SSOWat conf as skipped_uris
if [ "$is_public" = "Yes" ];
then
sudo yunohost app setting $app skipped_uris -v "/"
fi
# Restart services
sudo service nginx reload
sudo yunohost app ssowatconf

1
sources Submodule

@ -0,0 +1 @@
Subproject commit 2a59392ba8be974a5deec2e6f15959fde21186ea