Merge branch 'feature/redesign-prototype' of https://github.com/tugelbend/dir into feature/redesign-prototype
commit
31d3cb4889
@ -0,0 +1,43 @@
|
||||
|
||||
server_ip = "192.168.33.10"
|
||||
server_memory = "384" # MB
|
||||
server_timezone = "UTC"
|
||||
|
||||
public_folder = "/vagrant"
|
||||
|
||||
Vagrant.configure(2) do |config|
|
||||
|
||||
# Set server to Ubuntu 14.04
|
||||
config.vm.box = "ubuntu/trusty64"
|
||||
|
||||
# Disable automatic box update checking. If you disable this, then
|
||||
# boxes will only be checked for updates when the user runs
|
||||
# `vagrant box outdated`. This is not recommended.
|
||||
# config.vm.box_check_update = false
|
||||
|
||||
# Create a hostname, don't forget to put it to the `hosts` file
|
||||
# This will point to the server's default virtual host
|
||||
# TO DO: Make this work with virtualhost along-side xip.io URL
|
||||
config.vm.hostname = "friendica.dev"
|
||||
|
||||
# Create a static IP
|
||||
config.vm.network :private_network, ip: server_ip
|
||||
|
||||
# Share a folder between host and guest
|
||||
config.vm.synced_folder "./", "/vagrant/", owner: "www-data", group: "vagrant"
|
||||
|
||||
# Provider-specific configuration so you can fine-tune various
|
||||
# backing providers for Vagrant. These expose provider-specific options.
|
||||
config.vm.provider "virtualbox" do |vb|
|
||||
# # Display the VirtualBox GUI when booting the machine
|
||||
# vb.gui = true
|
||||
#
|
||||
# # Customize the amount of memory on the VM:
|
||||
vb.memory = server_memory
|
||||
end
|
||||
|
||||
# Enable provisioning with a shell script.
|
||||
config.vm.provision "shell", path: "./util/vagrant_provision.sh"
|
||||
# run: "always"
|
||||
# run: "once"
|
||||
end
|
@ -0,0 +1,237 @@
|
||||
# PHP-SSLLabs-API
|
||||
This PHP library provides basic access to the SSL Labs API.
|
||||
|
||||
It's build upon the official API documentation at https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md
|
||||
```PHP
|
||||
<?php
|
||||
|
||||
require_once 'sslLabsApi.php';
|
||||
|
||||
//Return API response as JSON string
|
||||
$api = new sslLabsApi();
|
||||
|
||||
//Return API response as JSON object
|
||||
//$api = new sslLabsApi(true);
|
||||
|
||||
//Set content-type header for JSON output
|
||||
header('Content-Type: application/json');
|
||||
|
||||
//get API information
|
||||
var_dump($api->fetchApiInfo());
|
||||
|
||||
?>
|
||||
```
|
||||
## Methods
|
||||
### fetchApiInfo()
|
||||
No parameters needed
|
||||
|
||||
Returns an Info object (see https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md#info).
|
||||
|
||||
### fetchStatusCodes()
|
||||
No parameters needed
|
||||
|
||||
Returns a StatusCodes instance (see https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md#statuscodes).
|
||||
|
||||
### fetchHostInformation()
|
||||
See https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md#invoke-assessment-and-check-progress for parameter description.
|
||||
|
||||
| Parameter | Type | Default value | |
|
||||
|---------------------|---------|---------------|----------|
|
||||
| **host** | string | | Required |
|
||||
| **publish** | boolean | false | |
|
||||
| **startNew** | boolean | false | |
|
||||
| **fromCache** | boolean | false | |
|
||||
| **maxAge** | int | null | |
|
||||
| **all** | string | null | |
|
||||
| **ignoreMismatch** | boolean | false | |
|
||||
|
||||
Returns a Host object (see https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md#host).
|
||||
|
||||
Make sure to check the 'status' attribute inside Host object.
|
||||
|
||||
### fetchHostInformationCached()
|
||||
You can also use fetchHostInformation() with the proper parameters, this is just a helper function.
|
||||
|
||||
| Parameter | Type | Default value | |
|
||||
|---------------------|---------|---------------|----------|
|
||||
| **host** | string | | Required |
|
||||
| **maxAge** | int | null | |
|
||||
| **publish** | boolean | false | |
|
||||
| **ignoreMismatch** | boolean | false | |
|
||||
|
||||
Returns a Host object (see https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md#host).
|
||||
|
||||
Also make sure to check the 'status' attribute inside Host object.
|
||||
|
||||
### fetchEndpointData()
|
||||
See https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md#retrieve-detailed-endpoint-information for parameter description.
|
||||
|
||||
| Parameter | Type | Default value | |
|
||||
|----------------|---------|---------------|----------|
|
||||
| **host** | string | | Required |
|
||||
| **s** | string | | Required |
|
||||
| **fromCache** | boolean | false | |
|
||||
|
||||
Returns an Endpoint object (see https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md#endpoint).
|
||||
|
||||
### Custom API calls
|
||||
Use sendApiRequest() method to create custom API calls.
|
||||
|
||||
| Parameter | Type | Default value | |
|
||||
|-----------------|--------|---------------|----------|
|
||||
| **apiCall** | string | | Required |
|
||||
| **parameters** | array | | |
|
||||
|
||||
```PHP
|
||||
$api->sendApiRequest('apiCallName', array('p1' => 'p1_value', 'p2' => 'p2_value'));
|
||||
```
|
||||
|
||||
### getReturnJsonObjects()
|
||||
Getter for returnJsonObjects
|
||||
|
||||
### setReturnJsonObjects()
|
||||
Setter for returnJsonObjects
|
||||
|
||||
| Parameter | Type | Default value | |
|
||||
|-----------------------|---------|---------------|----------|
|
||||
| **returnJsonObjects** | boolean | | Required |
|
||||
|
||||
## Example output (as JSON strings)
|
||||
### Get API information
|
||||
```PHP
|
||||
$api->fetchApiInfo();
|
||||
```
|
||||
```JSON
|
||||
{
|
||||
"engineVersion": "1.15.1",
|
||||
"criteriaVersion": "2009i",
|
||||
"clientMaxAssessments": 25,
|
||||
"maxAssessments": 25,
|
||||
"currentAssessments": 0,
|
||||
"messages": [
|
||||
"This assessment service is provided free of charge by Qualys SSL Labs, subject to our terms and conditions: https://www.ssllabs.com/about/terms.html"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Get host information
|
||||
```PHP
|
||||
$api->fetchHostInformation('https://www.google.de');
|
||||
```
|
||||
```JSON
|
||||
{
|
||||
"host": "https://www.google.de",
|
||||
"port": 443,
|
||||
"protocol": "HTTP",
|
||||
"isPublic": false,
|
||||
"status": "READY",
|
||||
"startTime": 1427195976527,
|
||||
"testTime": 1427196284525,
|
||||
"engineVersion": "1.15.1",
|
||||
"criteriaVersion": "2009i",
|
||||
"endpoints": [
|
||||
{
|
||||
"ipAddress": "74.125.239.119",
|
||||
"serverName": "nuq05s01-in-f23.1e100.net",
|
||||
"statusMessage": "Ready",
|
||||
"grade": "B",
|
||||
"hasWarnings": false,
|
||||
"isExceptional": false,
|
||||
"progress": 100,
|
||||
"duration": 77376,
|
||||
"eta": 1610,
|
||||
"delegation": 3
|
||||
},
|
||||
{
|
||||
"ipAddress": "74.125.239.120",
|
||||
"serverName": "nuq05s01-in-f24.1e100.net",
|
||||
"statusMessage": "Ready",
|
||||
"grade": "B",
|
||||
"hasWarnings": false,
|
||||
"isExceptional": false,
|
||||
"progress": 100,
|
||||
"duration": 76386,
|
||||
"eta": 1609,
|
||||
"delegation": 3
|
||||
},
|
||||
{
|
||||
"ipAddress": "74.125.239.127",
|
||||
"serverName": "nuq05s01-in-f31.1e100.net",
|
||||
"statusMessage": "Ready",
|
||||
"grade": "B",
|
||||
"hasWarnings": false,
|
||||
"isExceptional": false,
|
||||
"progress": 100,
|
||||
"duration": 76937,
|
||||
"eta": 1608,
|
||||
"delegation": 3
|
||||
},
|
||||
{
|
||||
"ipAddress": "74.125.239.111",
|
||||
"serverName": "nuq05s01-in-f15.1e100.net",
|
||||
"statusMessage": "Ready",
|
||||
"grade": "B",
|
||||
"hasWarnings": false,
|
||||
"isExceptional": false,
|
||||
"progress": 100,
|
||||
"duration": 77171,
|
||||
"eta": 1606,
|
||||
"delegation": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Get endpoint information
|
||||
```PHP
|
||||
$api->fetchEndpointData('https://www.google.de', '74.125.239.111');
|
||||
```
|
||||
|
||||
(just an except of the entire JSON output)
|
||||
```JSON
|
||||
{
|
||||
"ipAddress": "74.125.239.111",
|
||||
"serverName": "nuq05s01-in-f15.1e100.net",
|
||||
"statusMessage": "Ready",
|
||||
"grade": "B",
|
||||
"hasWarnings": false,
|
||||
"isExceptional": false,
|
||||
"progress": 100,
|
||||
"duration": 77171,
|
||||
"eta": 1609,
|
||||
"delegation": 3,
|
||||
"details": {
|
||||
"hostStartTime": 1427195976527,
|
||||
"key": {},
|
||||
"cert": {},
|
||||
"chain": {},
|
||||
"protocols": [],
|
||||
"suites": {},
|
||||
"serverSignature": "gws",
|
||||
"prefixDelegation": true,
|
||||
"nonPrefixDelegation": true,
|
||||
"vulnBeast": false,
|
||||
"renegSupport": 2,
|
||||
"sessionResumption": 1,
|
||||
"compressionMethods": 0,
|
||||
"supportsNpn": true,
|
||||
"npnProtocols": "h2-15 h2-14 spdy/3.1 spdy/3 http/1.1",
|
||||
"sessionTickets": 1,
|
||||
"ocspStapling": false,
|
||||
"sniRequired": false,
|
||||
"httpStatusCode": 200,
|
||||
"supportsRc4": true,
|
||||
"forwardSecrecy": 2,
|
||||
"rc4WithModern": true,
|
||||
"sims": {},
|
||||
"heartbleed": false,
|
||||
"heartbeat": false,
|
||||
"openSslCcs": 1,
|
||||
"poodleTls": 1,
|
||||
"fallbackScsv": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
# Terms and Conditions
|
||||
As this is just a PHP library for SSL Labs API please refer to SSL Labs terms and conditions at https://www.ssllabs.com/about/terms.html
|
@ -0,0 +1,216 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP-SSLLabs-API
|
||||
*
|
||||
* This PHP library provides basic access to the SSL Labs API
|
||||
* and is build upon the official API documentation at
|
||||
* https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md
|
||||
*
|
||||
* @author Björn Roland <https://github.com/bjoernr-de>
|
||||
* @license GNU GENERAL PUBLIC LICENSE v3
|
||||
*/
|
||||
|
||||
class sslLabsApi
|
||||
{
|
||||
CONST API_URL = "https://api.ssllabs.com/api/v2";
|
||||
|
||||
private $returnJsonObjects;
|
||||
|
||||
/**
|
||||
* sslLabsApi::__construct()
|
||||
*/
|
||||
public function __construct($returnJsonObjects = false)
|
||||
{
|
||||
$this->returnJsonObjects = (boolean) $returnJsonObjects;
|
||||
}
|
||||
|
||||
/**
|
||||
* sslLabsApi::fetchApiInfo()
|
||||
*
|
||||
* API Call: info
|
||||
* @see https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md
|
||||
*/
|
||||
public function fetchApiInfo()
|
||||
{
|
||||
return ($this->sendApiRequest('info'));
|
||||
}
|
||||
|
||||
/**
|
||||
* sslLabsApi::fetchHostInformation()
|
||||
*
|
||||
* API Call: analyze
|
||||
* @see https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md
|
||||
*
|
||||
* @param string $host Hostname to analyze
|
||||
* @param boolean $publish
|
||||
* @param boolean $startNew
|
||||
* @param boolean $fromCache
|
||||
* @param int $maxAge
|
||||
* @param string $all
|
||||
* @param boolean $ignoreMismatch
|
||||
*/
|
||||
public function fetchHostInformation($host, $publish = false, $startNew = false, $fromCache = false, $maxAge = NULL, $all = NULL, $ignoreMismatch = false)
|
||||
{
|
||||
$apiRequest = $this->sendApiRequest
|
||||
(
|
||||
'analyze',
|
||||
array
|
||||
(
|
||||
'host' => $host,
|
||||
'publish' => $publish,
|
||||
'startNew' => $startNew,
|
||||
'fromCache' => $fromCache,
|
||||
'maxAge' => $maxAge,
|
||||
'all' => $all,
|
||||
'ignoreMismatch' => $ignoreMismatch
|
||||
)
|
||||
);
|
||||
|
||||
return ($apiRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* sslLabsApi::fetchHostInformationCached()
|
||||
*
|
||||
* API Call: analyze
|
||||
* Same as fetchHostInformation() but prefer to receive cached information
|
||||
*
|
||||
* @param string $host
|
||||
* @param int $maxAge
|
||||
* @param string $publish
|
||||
* @param string $ignoreMismatch
|
||||
*/
|
||||
public function fetchHostInformationCached($host, $maxAge, $publish = false, $ignoreMismatch = false)
|
||||
{
|
||||
return($this->fetchHostInformation($host, $publish, false, true, $maxAge, 'done', $ignoreMismatch));
|
||||
}
|
||||
|
||||
/**
|
||||
* sslLabsApi::fetchEndpointData()
|
||||
*
|
||||
* API Call: getEndpointData
|
||||
* @see https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md
|
||||
*
|
||||
* @param string $host
|
||||
* @param string $s
|
||||
* @param string $fromCache
|
||||
* @return string
|
||||
*/
|
||||
public function fetchEndpointData($host, $s, $fromCache = false)
|
||||
{
|
||||
$apiRequest = $this->sendApiRequest
|
||||
(
|
||||
'getEndpointData',
|
||||
array
|
||||
(
|
||||
'host' => $host,
|
||||
's' => $s,
|
||||
'fromCache' => $fromCache
|
||||
)
|
||||
);
|
||||
|
||||
return ($apiRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* sslLabsApi::fetchStatusCodes()
|
||||
*
|
||||
* API Call: getStatusCodes
|
||||
*/
|
||||
public function fetchStatusCodes()
|
||||
{
|
||||
return ($this->sendApiRequest('getStatusCodes'));
|
||||
}
|
||||
|
||||
/**
|
||||
* sslLabsApi::sendApiRequest()
|
||||
*
|
||||
* Send API request
|
||||
*
|
||||
* @param string $apiCall
|
||||
* @param array $parameters
|
||||
* @return string JSON from API
|
||||
*/
|
||||
public function sendApiRequest($apiCall, $parameters = array())
|
||||
{
|
||||
//we also want content from failed api responses
|
||||
$context = stream_context_create
|
||||
(
|
||||
array
|
||||
(
|
||||
'http' => array
|
||||
(
|
||||
'ignore_errors' => true
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$apiResponse = file_get_contents(self::API_URL . '/' . $apiCall . $this->buildGetParameterString($parameters), false, $context);
|
||||
|
||||
if($this->returnJsonObjects)
|
||||
{
|
||||
return (json_decode($apiResponse));
|
||||
}
|
||||
|
||||
return ($apiResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* sslLabsApi::setReturnJsonObjects()
|
||||
*
|
||||
* Setter for returnJsonObjects
|
||||
* Set true to return all API responses as JSON object, false returns it as simple JSON strings (default)
|
||||
*
|
||||
* @param boolean $returnJsonObjects
|
||||
*/
|
||||
public function setReturnJsonObjects($returnJsonObjects)
|
||||
{
|
||||
$this->returnJsonObjects = (boolean) $returnJsonObjects;
|
||||
}
|
||||
|
||||
/**
|
||||
* sslLabsApi::getReturnJsonObjects()
|
||||
*
|
||||
* Getter for returnJsonObjects
|
||||
*
|
||||
* @return boolean true returns all API responses as JSON object, false returns it as simple JSON string
|
||||
*/
|
||||
public function getReturnJsonObjects()
|
||||
{
|
||||
return ($this->returnJsonObjects);
|
||||
}
|
||||
|
||||
/**
|
||||
* sslLabsApi::buildGetParameterString()
|
||||
*
|
||||
* Helper function to build get parameter string for URL
|
||||
*
|
||||
* @param array $parameters
|
||||
* @return string
|
||||
*/
|
||||
private function buildGetParameterString($parameters)
|
||||
{
|
||||
$string = '';
|
||||
|
||||
$counter = 0;
|
||||
foreach($parameters as $name => $value)
|
||||
{
|
||||
if(!is_string($name) || (!is_string($value) && !is_bool($value) && !is_int($value)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(is_bool($value))
|
||||
{
|
||||
$value = ($value) ? 'on' : 'off';
|
||||
}
|
||||
|
||||
$string .= ($counter == 0) ? '?' : '&';
|
||||
$string .= urlencode($name) . '=' . urlencode($value);
|
||||
|
||||
$counter++;
|
||||
}
|
||||
|
||||
return ($string);
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
use Friendica\Directory\Rendering\View;
|
||||
|
||||
if(! function_exists('help_content')) {
|
||||
function help_content(&$a) {
|
||||
$view = new View('help');
|
||||
$view->output();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
use Friendica\Directory\Rendering\View;
|
||||
|
||||
if(! function_exists('stats_content')) {
|
||||
function stats_content(&$a) {
|
||||
$view = new View('stats');
|
||||
$view->output();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
<div class="sites">
|
||||
<div>
|
||||
<h1>Help</h1>
|
||||
<h2>Registering a Friendica account (with an existing server)</h2>
|
||||
<h2>Setting up a Friendica server</h2>
|
||||
<h2>Finding people - Getting new friends</h2>
|
||||
<h2>More help</h2>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,5 @@
|
||||
<div class="sites">
|
||||
<div>
|
||||
<h1>Stats</h1>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
//MySQL host.
|
||||
$db_host = 'localhost';
|
||||
$db_user = 'root';
|
||||
$db_pass = 'root';
|
||||
$db_data = 'friendica_dir';
|
||||
|
||||
// Choose a legal default timezone. If you are unsure, use "America/Los_Angeles".
|
||||
// It can be changed later and only applies to timestamps for anonymous viewers.
|
||||
$default_timezone = 'Europe/Amsterdam';
|
||||
|
||||
// What is your site name?
|
||||
$a->config['sitename'] = "EXPERIMENTAL Friendica public directory";
|
||||
|
||||
//Statistic display settings.
|
||||
$a->config['stats'] = array(
|
||||
|
||||
//For site health, the max age for which to display data.
|
||||
'maxDataAge' => 3600*24*30*4 //120 days = ~4 months
|
||||
|
||||
);
|
||||
|
||||
//Settings related to the syncing feature.
|
||||
$a->config['syncing'] = array(
|
||||
|
||||
//Pulling may be quite intensive at first when it has to do a full sync and your directory is empty.
|
||||
//This timeout should be shorter than your cronjob interval. Preferably with a little breathing room.
|
||||
'timeout' => 3*60, //3 minutes
|
||||
|
||||
//Push new submits to the `sync-target` entries?
|
||||
'enable_pushing' => true,
|
||||
|
||||
//Maximum amount of items per batch per target to push to other sync-targets.
|
||||
//For example: 3 targets x20 items = 60 requests.
|
||||
'max_push_items' => 10,
|
||||
|
||||
//Pull updates from the `sync-target` entries?
|
||||
'enable_pulling' => true,
|
||||
|
||||
//This is your normal amount of threads for pulling.
|
||||
//With regular intervals, there's no need to give this a high value.
|
||||
//But when your server is brand new, you may want to keep this high for the first day or two.
|
||||
'pulling_threads' => 25,
|
||||
|
||||
//How many items should we crawl per sync?
|
||||
'max_pull_items' => 250
|
||||
|
||||
);
|
||||
|
||||
//Things related to site-health monitoring.
|
||||
$a->config['site-health'] = array(
|
||||
|
||||
//Wait for at least ... before probing a site again.
|
||||
//The longer this value, the more "stable" site-healths will be over time.
|
||||
//Note: If a bad (negative) health site submits something, a probe will be performed regardless.
|
||||
'min_probe_delay' => 24*3600, // 1 day
|
||||
|
||||
//Probes get a simple /friendica/json file from the server.
|
||||
//Feel free to set this timeout to a very tight value.
|
||||
'probe_timeout' => 5, // seconds
|
||||
|
||||
//Imports should be fast. Feel free to prioritize healthy sites.
|
||||
'skip_import_threshold' => -20
|
||||
|
||||
);
|
||||
|
||||
//Things related to the maintenance cronjob.
|
||||
$a->config['maintenance'] = array(
|
||||
|
||||
//This is to prevent I/O blocking. Will cost you some RAM overhead though.
|
||||
//A good server should handle much more than this default, so you can tweak this.
|
||||
'threads' => 10,
|
||||
|
||||
//Limit the amount of scrapes per execution of the maintainer.
|
||||
//This will depend a lot on the frequency with which you call the maintainer.
|
||||
//If you have 10 threads and 80 max_scrapes, that means each thread will handle 8 scrapes.
|
||||
'max_scrapes' => 80,
|
||||
|
||||
//Wait for at least ... before scraping a profile again.
|
||||
'min_scrape_delay' => 3*24*3600, // 3 days
|
||||
|
||||
//At which health value should we start removing profiles?
|
||||
'remove_profile_health_threshold' => -60
|
||||
|
||||
);
|
@ -0,0 +1,5 @@
|
||||
--
|
||||
-- Sync targets to poulate the development directory
|
||||
--
|
||||
INSERT INTO `friendica_dir`.`sync-targets` (`base_url`, `pull`, `push`, `dt_last_pull`) VALUES ('dir.friendica.com', 1, 0, '');
|
||||
INSERT INTO `friendica_dir`.`sync-targets` (`base_url`, `pull`, `push`, `dt_last_pull`) VALUES ('dir.friendi.ca', 1, 0, '');
|
@ -0,0 +1,84 @@
|
||||
#!/bin/bash
|
||||
#Script to setup the vagrant instance for running friendica
|
||||
#
|
||||
#DO NOT RUN on your physical machine as this won't be of any use
|
||||
#and f.e. deletes your /var/www/ folder!
|
||||
echo "Friendica configuration settings"
|
||||
sudo apt-get update
|
||||
|
||||
#Selfsigned cert
|
||||
echo ">>> Installing *.xip.io self-signed SSL"
|
||||
SSL_DIR="/etc/ssl/xip.io"
|
||||
DOMAIN="*.xip.io"
|
||||
PASSPHRASE="vaprobash"
|
||||
SUBJ="
|
||||
C=US
|
||||
ST=Connecticut
|
||||
O=Vaprobash
|
||||
localityName=New Haven
|
||||
commonName=$DOMAIN
|
||||
organizationalUnitName=
|
||||
emailAddress=
|
||||
"
|
||||
sudo mkdir -p "$SSL_DIR"
|
||||
sudo openssl genrsa -out "$SSL_DIR/xip.io.key" 4096
|
||||
sudo openssl req -new -subj "$(echo -n "$SUBJ" | tr "\n" "/")" -key "$SSL_DIR/xip.io.key" -out "$SSL_DIR/xip.io.csr" -passin pass:$PASSPHRASE
|
||||
sudo openssl x509 -req -days 365 -in "$SSL_DIR/xip.io.csr" -signkey "$SSL_DIR/xip.io.key" -out "$SSL_DIR/xip.io.crt"
|
||||
|
||||
|
||||
#Install apache2
|
||||
echo ">>> Installing Apache2 webserver"
|
||||
sudo apt-get install -y apache2
|
||||
sudo a2enmod rewrite actions ssl
|
||||
sudo cp /vagrant/util/vagrant_vhost.sh /usr/local/bin/vhost
|
||||
sudo chmod guo+x /usr/local/bin/vhost
|
||||
sudo vhost -s 192.168.33.10.xip.io -d /var/www -p /etc/ssl/xip.io -c xip.io -a friendica.dev
|
||||
sudo a2dissite 000-default
|
||||
sudo service apache2 restart
|
||||
|
||||
#Install php
|
||||
echo ">>> Installing PHP5"
|
||||
sudo apt-get install -y php5 libapache2-mod-php5 php5-cli php5-mysql php5-curl php5-gd
|
||||
sudo service apache2 restart
|
||||
|
||||
|
||||
#Install mysql
|
||||
echo ">>> Installing Mysql"
|
||||
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password root"
|
||||
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password root"
|
||||
sudo apt-get install -qq mysql-server
|
||||
# enable remote access
|
||||
# setting the mysql bind-address to allow connections from everywhere
|
||||
sed -i "s/bind-address.*/bind-address = 0.0.0.0/" /etc/mysql/my.cnf
|
||||
# adding grant privileges to mysql root user from everywhere
|
||||
# thx to http://stackoverflow.com/questions/7528967/how-to-grant-mysql-privileges-in-a-bash-script for this
|
||||
MYSQL=`which mysql`
|
||||
Q1="GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;"
|
||||
Q2="FLUSH PRIVILEGES;"
|
||||
SQL="${Q1}${Q2}"
|
||||
$MYSQL -uroot -proot -e "$SQL"
|
||||
service mysql restart
|
||||
|
||||
#make the vagrant directory the docroot
|
||||
sudo rm -rf /var/www/
|
||||
sudo ln -fs /vagrant /var/www
|
||||
|
||||
# initial config file for friendica in vagrant
|
||||
cp /vagrant/util/htconfig.vagrant.php /vagrant/.htconfig.php
|
||||
|
||||
# create the friendica database
|
||||
echo "create database friendica_dir" | mysql -u root -proot
|
||||
# import test database
|
||||
$MYSQL -uroot -proot friendica_dir < /vagrant/dfrndir.sql
|
||||
$MYSQL -uroot -proot friendica_dir < /vagrant/util/vagrant_default_sync_servers.sql
|
||||
|
||||
#Install composer
|
||||
cd /vagrant
|
||||
curl -sS https://getcomposer.org/installer | php
|
||||
php composer.phar install
|
||||
|
||||
#create cronjob
|
||||
echo "*/30 * * * * www-data cd /vagrant; php include/cron_maintain.php" >> friendicacron
|
||||
echo "*/5 * * * * www-data cd /vagrant; php include/cron_sync.php" >> friendicacron
|
||||
sudo crontab friendicacron
|
||||
sudo rm friendicacron
|
@ -0,0 +1,177 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Run this as sudo!
|
||||
# I move this file to /usr/local/bin/vhost and run command 'vhost' from anywhere, using sudo.
|
||||
|
||||
#
|
||||
# Show Usage, Output to STDERR
|
||||
#
|
||||
function show_usage {
|
||||
cat <<- _EOF_
|
||||
|
||||
Create a new vHost in Ubuntu Server
|
||||
Assumes /etc/apache2/sites-available and /etc/apache2/sites-enabled setup used
|
||||
|
||||
-d DocumentRoot - i.e. /var/www/yoursite
|
||||
-h Help - Show this menu.
|
||||
-s ServerName - i.e. example.com or sub.example.com
|
||||
-a ServerAlias - i.e. *.example.com or another domain altogether
|
||||
-p File path to the SSL certificate. Directories only, no file name.
|
||||
If using an SSL Certificate, also creates a port :443 vhost as well.
|
||||
This *ASSUMES* a .crt and a .key file exists
|
||||
at file path /provided-file-path/your-server-or-cert-name.[crt|key].
|
||||
Otherwise you can except Apache errors when you reload Apache.
|
||||
Ensure Apache's mod_ssl is enabled via "sudo a2enmod ssl".
|
||||
-c Certificate filename. "xip.io" becomes "xip.io.key" and "xip.io.crt".
|
||||
|
||||
Example Usage. Serve files from /var/www/xip.io at http(s)://192.168.33.10.xip.io
|
||||
using ssl files from /etc/ssl/xip.io/xip.io.[key|crt]
|
||||
sudo vhost -d /var/www/xip.io -s 192.168.33.10.xip.io -p /etc/ssl/xip.io -c xip.io
|
||||
|
||||
_EOF_
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Output vHost skeleton, fill with userinput
|
||||
# To be outputted into new file
|
||||
#
|
||||
function create_vhost {
|
||||
cat <<- _EOF_
|
||||
<VirtualHost *:80>
|
||||
ServerAdmin webmaster@localhost
|
||||
ServerName $ServerName
|
||||
$ServerAlias
|
||||
|
||||
DocumentRoot $DocumentRoot
|
||||
|
||||
|
||||
<Directory $DocumentRoot>
|
||||
Options Indexes FollowSymLinks MultiViews
|
||||
AllowOverride All
|
||||
Order allow,deny
|
||||
allow from all
|
||||
</Directory>
|
||||
|
||||
ErrorLog \${APACHE_LOG_DIR}/$ServerName-error.log
|
||||
|
||||
# Possible values include: debug, info, notice, warn, error, crit,
|
||||
# alert, emerg.
|
||||
LogLevel warn
|
||||
|
||||
CustomLog \${APACHE_LOG_DIR}/$ServerName-access.log combined
|
||||
|
||||
|
||||
</VirtualHost>
|
||||
_EOF_
|
||||
}
|
||||
|
||||
function create_ssl_vhost {
|
||||
cat <<- _EOF_
|
||||
<VirtualHost *:443>
|
||||
ServerAdmin webmaster@localhost
|
||||
ServerName $ServerName
|
||||
$ServerAlias
|
||||
|
||||
DocumentRoot $DocumentRoot
|
||||
|
||||
<Directory $DocumentRoot>
|
||||
Options Indexes FollowSymLinks MultiViews
|
||||
AllowOverride All
|
||||
Order allow,deny
|
||||
allow from all
|
||||
</Directory>
|
||||
|
||||
ErrorLog \${APACHE_LOG_DIR}/$ServerName-error.log
|
||||
|
||||
# Possible values include: debug, info, notice, warn, error, crit,
|
||||
# alert, emerg.
|
||||
LogLevel warn
|
||||
|
||||
CustomLog \${APACHE_LOG_DIR}/$ServerName-access.log combined
|
||||
|
||||
SSLEngine on
|
||||
|
||||
SSLCertificateFile $CertPath/$CertName.crt
|
||||
SSLCertificateKeyFile $CertPath/$CertName.key
|
||||
|
||||
<FilesMatch "\.(cgi|shtml|phtml|php)$">
|
||||
SSLOptions +StdEnvVars
|
||||
</FilesMatch>
|
||||
|
||||
BrowserMatch "MSIE [2-6]" \\
|
||||
nokeepalive ssl-unclean-shutdown \\
|
||||
downgrade-1.0 force-response-1.0
|
||||
# MSIE 7 and newer should be able to use keepalive
|
||||
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
|
||||
</VirtualHost>
|
||||
_EOF_
|
||||
}
|
||||
|
||||
#Sanity Check - are there two arguments with 2 values?
|
||||
if [ "$#" -lt 4 ]; then
|
||||
show_usage
|
||||
fi
|
||||
|
||||
CertPath=""
|
||||
|
||||
#Parse flags
|
||||
while getopts "d:s:a:p:c:h" OPTION; do
|
||||
case $OPTION in
|
||||
h)
|
||||
show_usage
|
||||
;;
|
||||
d)
|
||||
DocumentRoot=$OPTARG
|
||||
;;
|
||||
s)
|
||||
ServerName=$OPTARG
|
||||
;;
|
||||
a)
|
||||
Alias=$OPTARG
|
||||
;;
|
||||
p)
|
||||
CertPath=$OPTARG
|
||||
;;
|
||||
c)
|
||||
CertName=$OPTARG
|
||||
;;
|
||||
*)
|
||||
show_usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# If alias is set:
|
||||
if [ "$Alias" != "" ]; then
|
||||
ServerAlias="ServerAlias "$Alias
|
||||
else
|
||||
ServerAlias=""
|
||||
fi
|
||||
|
||||
# If CertName doesn't get set, set it to ServerName
|
||||
if [ "$CertName" == "" ]; then
|
||||
CertName=$ServerName
|
||||
fi
|
||||
|
||||
if [ ! -d $DocumentRoot ]; then
|
||||
mkdir -p $DocumentRoot
|
||||
#chown USER:USER $DocumentRoot #POSSIBLE IMPLEMENTATION, new flag -u ?
|
||||
fi
|
||||
|
||||
if [ -f "$DocumentRoot/$ServerName.conf" ]; then
|
||||
echo 'vHost already exists. Aborting'
|
||||
show_usage
|
||||
else
|
||||
create_vhost > /etc/apache2/sites-available/${ServerName}.conf
|
||||
|
||||
# Add :443 handling
|
||||
if [ "$CertPath" != "" ]; then
|
||||
create_ssl_vhost >> /etc/apache2/sites-available/${ServerName}.conf
|
||||
fi
|
||||
|
||||
# Enable Site
|
||||
cd /etc/apache2/sites-available/ && a2ensite ${ServerName}.conf
|
||||
service apache2 reload
|
||||
fi
|
Loading…
Reference in new issue