Update Giancoli v6 to use Circ.asy v0.2.
[course.git] / local-install.sh
1 #!/bin/bash
2 #
3 # By default, this website is setup for remote installation via SSH.
4 # This works well if you've setup SSH keys for passwordless login, but
5 # is annoying otherwise.
6 #
7 # An alternative setup would be to keep the source code on the same
8 # machine as the webserver, and use local CP calls to push the data
9 # into the hosted directory.  This script converts the default
10 # codebase into such a local installation.
11 #
12 # Usage: ./local-install.sh
13
14 set -e # exit immediately on failed command
15 set -o pipefail # pipes fail if any stage fails
16 set -v # verbose, echo commands to stdout
17
18 echo -e "\nRemove the INSTALL_HOST/USER lines in ./Makefile.\n"
19 sed -i 's/^INSTALL_HOST =.*//' ./Makefile
20 sed -i 's/^INSTALL_USER =.*//' ./Makefile
21 sed -i 's/^export INSTALL_HOST.*//' ./Makefile
22 sed -i 's/^export INSTALL_USER.*//' ./Makefile
23
24 echo -e "\nReplace the SCP with a local CP in all Makefiles.\n"
25 sed -i 's/scp -p \(.*\) \$(INSTALL_USER)@\$(INSTALL_HOST):\(.*\)$/cp -up \1 \2/' \
26     $(find . -name Makefile)
27
28
29 echo -e "\nNo need to SSH into installation host to make directories.\n"
30 # merge first two lines of multi-line SSH calls
31 sed -i '
32 # look for multi-line SSH calls
33 /ssh \$(INSTALL_USER)@\$(INSTALL_HOST) \\/ {
34 # got one, read in the next line
35                                           N
36 # concatenate the two lines
37                                           s/\\\n\t *//
38 }' $(find . -name Makefile)
39 # fix the single-line calls (now all the calls)
40 sed -i 's/ssh \$(INSTALL_USER)@\$(INSTALL_HOST) \(.*\)$/\1/' \
41     $(find . -name Makefile)
42
43
44 echo -e "\nCorrect a few particular details.\n"
45 # correct a comment
46 sed -i 's/INSTALL_USER, INSTALL_HOST, //' latex/notes/topics/linear_algebra/Makefile
47 # adjust shell ecscaping for newly non-SSHed command
48 sed -i "/cd \\\$(INSTALL_DIR) '&&' rm/ { s/'&&'/\&\&/g }" html/Makefile
49 #sed -i "s/'&&'/\&\&/" html/Makefile
50
51
52 echo -e "\nStandardize INSTALL_DIR destination in ./Makefile.\n"
53 sed -i 's/^INSTALL_DIR = .*/INSTALL_DIR = ~\/public_html\//' Makefile