diff options
author | nodiscc <nodiscc@gmail.com> | 2015-03-15 14:21:33 +0100 |
---|---|---|
committer | nodiscc <nodiscc@gmail.com> | 2015-03-15 14:21:33 +0100 |
commit | bc66d513a9aa6da9361dbfc2f0b4bf384e9597a6 (patch) | |
tree | 204253dc05d4b21e59d10449c8d6bae551ab6e53 /doc/Copy-a-Shaarli-installation-over-SSH-SCP,-serve-it-locally-with-php-cli.md | |
parent | 4f8063b6394351749dee7fa3f5ab23cacbbd19a8 (diff) | |
parent | 1acc87eeac036b3ccfad5553b9092899cf2ecaa0 (diff) | |
download | Shaarli-bc66d513a9aa6da9361dbfc2f0b4bf384e9597a6.tar.gz Shaarli-bc66d513a9aa6da9361dbfc2f0b4bf384e9597a6.tar.zst Shaarli-bc66d513a9aa6da9361dbfc2f0b4bf384e9597a6.zip |
Merge branch 'include-doc' into next
Diffstat (limited to 'doc/Copy-a-Shaarli-installation-over-SSH-SCP,-serve-it-locally-with-php-cli.md')
-rw-r--r-- | doc/Copy-a-Shaarli-installation-over-SSH-SCP,-serve-it-locally-with-php-cli.md | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/doc/Copy-a-Shaarli-installation-over-SSH-SCP,-serve-it-locally-with-php-cli.md b/doc/Copy-a-Shaarli-installation-over-SSH-SCP,-serve-it-locally-with-php-cli.md new file mode 100644 index 00000000..5b0aec6f --- /dev/null +++ b/doc/Copy-a-Shaarli-installation-over-SSH-SCP,-serve-it-locally-with-php-cli.md | |||
@@ -0,0 +1,66 @@ | |||
1 | Example bash script: | ||
2 | |||
3 | ``` | ||
4 | #!/bin/bash | ||
5 | #Description: Copy a Shaarli installation over SSH/SCP, serve it locally with php-cli | ||
6 | #Will create a local-shaarli/ directory when you run it, backup your Shaarli there, and serve it locally. | ||
7 | #Will NOT download linked pages. It's just a directly usable backup/copy/mirror of your Shaarli | ||
8 | #Requires: ssh, scp and a working SSH access to the server where your Shaarli is installed | ||
9 | #Usage: ./local-shaarli.sh | ||
10 | #Author: nodiscc (nodiscc@gmail.com) | ||
11 | #License: MIT (http://opensource.org/licenses/MIT) | ||
12 | set -o errexit | ||
13 | set -o nounset | ||
14 | |||
15 | ##### CONFIG ################# | ||
16 | #The port used by php's local server | ||
17 | php_local_port=7431 | ||
18 | |||
19 | #Name of the SSH server and path where Shaarli is installed | ||
20 | #TODO: pass these as command-line arguments | ||
21 | remotehost="my.ssh.server" | ||
22 | remote_shaarli_dir="/var/www/shaarli" | ||
23 | |||
24 | |||
25 | ###### FUNCTIONS ############# | ||
26 | _main() { | ||
27 | _CBSyncShaarli | ||
28 | _CBServeShaarli | ||
29 | } | ||
30 | |||
31 | _CBSyncShaarli() { | ||
32 | remote_temp_dir=$(ssh $remotehost mktemp -d) | ||
33 | remote_ssh_user=$(ssh $remotehost whoami) | ||
34 | ssh -t "$remotehost" sudo cp -r "$remote_shaarli_dir" "$remote_temp_dir" | ||
35 | ssh -t "$remotehost" sudo chown -R "$remote_ssh_user":"$remote_ssh_user" "$remote_temp_dir" | ||
36 | scp -rq "$remotehost":"$remote_temp_dir" local-shaarli | ||
37 | ssh "$remotehost" rm -r "$remote_temp_dir" | ||
38 | } | ||
39 | |||
40 | _CBServeShaarli() { | ||
41 | #TODO: allow serving a previously downloaded Shaarli | ||
42 | #TODO: ask before overwriting local copy, if it exists | ||
43 | cd local-shaarli/ | ||
44 | php -S localhost:${php_local_port} | ||
45 | echo "Please go to http://localhost:${php_local_port}" | ||
46 | } | ||
47 | |||
48 | |||
49 | ##### MAIN ################# | ||
50 | |||
51 | _main | ||
52 | ``` | ||
53 | |||
54 | This outputs: | ||
55 | |||
56 | ``` | ||
57 | $ ./local-shaarli.sh | ||
58 | PHP 5.6.0RC4 Development Server started at Mon Sep 1 21:56:19 2014 | ||
59 | Listening on http://localhost:7431 | ||
60 | Document root is /home/user/local-shaarli/shaarli | ||
61 | Press Ctrl-C to quit. | ||
62 | |||
63 | [Mon Sep 1 21:56:27 2014] ::1:57868 [200]: / | ||
64 | [Mon Sep 1 21:56:27 2014] ::1:57869 [200]: /index.html | ||
65 | [Mon Sep 1 21:56:37 2014] ::1:57881 [200]: /... | ||
66 | ``` \ No newline at end of file | ||