diff options
author | ArthurHoaro <arthur@hoa.ro> | 2016-10-12 13:58:35 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2016-10-12 13:58:35 +0200 |
commit | bc22c9a0acb095970e9494cbe8954f0612e05dc0 (patch) | |
tree | 4e3a94b7469f5b2e3eaf946756235730429bf9d4 /doc/Create-and-serve-multiple-Shaarlis-(farm).md | |
parent | 890afc32f744859d11b97eb26ed5c030af9b4145 (diff) | |
parent | ebd67c6e1b40aebdd3a52285ce9ff9412b2a3038 (diff) | |
download | Shaarli-bc22c9a0acb095970e9494cbe8954f0612e05dc0.tar.gz Shaarli-bc22c9a0acb095970e9494cbe8954f0612e05dc0.tar.zst Shaarli-bc22c9a0acb095970e9494cbe8954f0612e05dc0.zip |
Merge tag 'v0.7.0' of github.com:shaarli/Shaarli into stable
Release v0.7.0
Diffstat (limited to 'doc/Create-and-serve-multiple-Shaarlis-(farm).md')
-rw-r--r-- | doc/Create-and-serve-multiple-Shaarlis-(farm).md | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/doc/Create-and-serve-multiple-Shaarlis-(farm).md b/doc/Create-and-serve-multiple-Shaarlis-(farm).md new file mode 100644 index 00000000..a71f6520 --- /dev/null +++ b/doc/Create-and-serve-multiple-Shaarlis-(farm).md | |||
@@ -0,0 +1,58 @@ | |||
1 | #Create and serve multiple Shaarlis (farm) | ||
2 | Example bash script (creates multiple shaarli instances and generates an HTML index of them) | ||
3 | |||
4 | ```bash | ||
5 | #!/bin/bash | ||
6 | set -o errexit | ||
7 | set -o nounset | ||
8 | |||
9 | #config | ||
10 | shaarli_base_dir='/var/www/shaarli' | ||
11 | accounts='bob john whatever username' | ||
12 | shaarli_repo_url='https://github.com/shaarli/Shaarli' | ||
13 | ref="master" | ||
14 | |||
15 | #clone multiple shaarli instances | ||
16 | if [ ! -d "$shaarli_base_dir" ]; then mkdir "$shaarli_base_dir"; fi[](.html) | ||
17 | |||
18 | for account in $accounts; do | ||
19 | if [ -d "$shaarli_base_dir/$account" ];[](.html) | ||
20 | then echo "[info] account $account already exists, skipping";[](.html) | ||
21 | else echo "[info] creating new account $account ..."; git clone --quiet "$shaarli_repo_url" -b "$ref" "$shaarli_base_dir/$account"; fi[](.html) | ||
22 | done | ||
23 | |||
24 | #generate html index of shaarlis | ||
25 | htmlhead='<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
26 | <!-- Minimal html template thanks to http://www.sitepoint.com/a-minimal-html-document/ --> | ||
27 | <html lang="en"> | ||
28 | <head> | ||
29 | <meta http-equiv="content-type" content="text/html; charset=utf-8"> | ||
30 | <title>My Shaarli farm</title> | ||
31 | <style>body {font-family: "Open Sans"}</style> | ||
32 | </head> | ||
33 | <body> | ||
34 | <div> | ||
35 | <h1>My Shaarli farm</h1> | ||
36 | <ul style="list-style-type: none;">' | ||
37 | |||
38 | accountlinks='' | ||
39 | |||
40 | htmlfooter=' | ||
41 | </ul> | ||
42 | </div> | ||
43 | </body> | ||
44 | </html>' | ||
45 | |||
46 | |||
47 | |||
48 | for account in $accounts; do accountlinks="$accountlinks\n<li><a href=\"$account\">$account</a></li>"; done | ||
49 | if [ -d "$shaarli_base_dir/index.html" ]; then echo "[removing old index.html]"; rm "$shaarli_base_dir/index.html" ]; fi[](.html) | ||
50 | echo "[info] generating new index of shaarlis"[](.html) | ||
51 | echo -e "$htmlhead $accountlinks $htmlfooter" > "$shaarli_base_dir/index.html" | ||
52 | echo '[info] done.'[](.html) | ||
53 | echo "[info] list of accounts: $accounts"[](.html) | ||
54 | echo "[info] contents of $shaarli_base_dir:"[](.html) | ||
55 | tree -a -L 1 "$shaarli_base_dir" | ||
56 | ``` | ||
57 | |||
58 | This script just serves as an example. More precise or complex (applying custom configuration, etc) automation is possible using configuration management software like [Ansible](https://www.ansible.com/)[](.html) | ||