Skip to content

Commit 529a729

Browse files
committed
makeservices: add easydoku script
Strucured similarly to the easywp script, this installs DokuWiki. It includes a prompt for subfolder, since some groups might want this at a separate URL.
1 parent 9e27fc2 commit 529a729

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

makeservices/easydoku

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/bash
2+
3+
# Creates symlink to user's webroot. If the symlink exists and files
4+
# are present in webroot, they are backed up in the user's home directory.
5+
# DokuWiki and the upgrade plugin are installed in the chosen directory.
6+
#
7+
8+
set -euo pipefail
9+
shopt -s dotglob
10+
11+
if ! [[ "$(hostname)" =~ (dev-)?tsunami ]]; then
12+
echo -e '\033[1;31mYou must run this command on tsunami.\033[0m'
13+
exit 1
14+
fi
15+
16+
user=$(whoami)
17+
18+
echo "What subfolder would you like to install DokuWiki in?"
19+
echo "Example: type nothing for root (https://www.ocf.berkeley.edu/~$(whoami))"
20+
echo "Example: type \"wiki\" for wiki subfolder (https://www.ocf.berkeley.edu/~$(whoami)/wiki)"
21+
22+
read -r subfolder
23+
24+
read -rp "Are you sure you want to continue? [y/N] " idunno
25+
idunno=${idunno,,}
26+
if ! [[ "$idunno" =~ ^(yes|y) ]]; then
27+
echo "Ok, bye!"
28+
exit 0
29+
fi
30+
31+
webroot=$HOME/public_html/"$subfolder"
32+
33+
# Create symlink to webroot
34+
makehttp
35+
36+
mkdir -p "$webroot"
37+
cd "$webroot"
38+
39+
# Check if user has files and let user decide what they want to do.
40+
if [[ -n "$(ls -A)" ]]; then
41+
echo
42+
echo -e "\033[33mThere are currently files in webroot! These will be backed up.\033[00m\n"
43+
read -rp "Do you want to continue? [y/N] " whoknows
44+
45+
whoknows=${whoknows,,}
46+
if [[ "$whoknows" =~ ^(yes|y) ]]; then
47+
ts=$(date +"%Y-%m-%d_%H:%M:%S")
48+
backup="$HOME/public_html-$ts"
49+
mkdir -p "$backup"
50+
echo "Moving current files to $backup ..."
51+
# Note that dotglob is set so hidden files are moved too
52+
mv ./* "$backup"
53+
else
54+
echo "Ok, bye!"
55+
exit 0
56+
fi
57+
fi
58+
59+
echo "Downloading and installing DokuWiki"
60+
curl -L "https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz" \
61+
| tar -xz --strip-components=1
62+
63+
echo "Downloading and installing the Upgrade plugin"
64+
mkdir lib/plugins/upgrade
65+
curl -L "https://github.com/splitbrain/dokuwiki-plugin-upgrade/tarball/master" \
66+
| tar -xz -C lib/plugins/upgrade --strip-components=1
67+
68+
echo "DokuWiki install successful. Go to https://www.ocf.berkeley.edu/~$user/$subfolder to finish the setup process."

0 commit comments

Comments
 (0)