2 # Copyright (C) 2016 Ian Kelling
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # This script depends on a few other git repos of mine, such as
18 # distro-functions, basic-https-conf, acme-tiny-wrapper
21 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
25 Usage: ${0##*/} [-h|--help] [DOMAIN_NAME]
26 Setup dependencies, apache, and gitweb. Then call build.rb.
28 Default DOMAIN_NAME is iankelling.org. Domain is expected to resolve
29 so we can get a let's encrypt cert.
32 -h|--help Print help and exit.
34 Note: Uses GNU getopt options parsing style
39 ##### begin command line parsing ########
41 temp
=$
(getopt
-l help, h
"$@") || usage
1
47 *) echo "$0: Internal error! unexpected args: $*" ; exit 1 ;;
51 ##### end command line parsing ########
53 x
="$(readlink -f "$BASH_SOURCE")"
57 domain
=${1:-iankelling.org} # use argument for testing site
58 gitroot
=/a
/bin
/githtml
60 if [[ $EUID != 0 ]]; then
65 if grep -xFq 'VERSION_ID="8"' /etc
/os-release
; then
71 type -P a2enmod
&>/dev
/null ||
$s apt-get
-y install apache2
72 type -P sqlite3
&>/dev
/null ||
$s apt-get
-y install sqlite3
75 acme-tiny-wrapper
$domain
78 # build.rb dependencies
79 ruby-pygments.rb ruby-safe-yaml ruby-sass
80 # python pkgs used for o(n^2) voting blog entry
81 python-bcrypt python-passlib
86 pkgs
+=(build-essential ruby-dev
)
88 pkgs
+=(ruby-redcarpet
)
91 $s apt-get
-y install ${pkgs[@]}
93 sudo gem
install redcarpet
95 chmod og
+x _site
/on2vote
/vote.py
98 # debian has the package gitweb, which seems to mainly
99 # have some example apache config, and a minimal gitweb config.
100 # I'll just use the config as example and not use the package.
101 # It's example apache config seems to say we can use cgi or cgid,
102 # and googling cgid it seems a newer faster alternative. I also
103 # depend on this in my o(n^2) python script.
107 # additional settings from browsing https://git-scm.com/docs/gitweb.conf
108 $s dd of
=/etc
/gitweb.conf
<<EOF
109 \$feature{'highlight'}{'default'} = [1];
110 # highlighting doesn't work on files without extension.
111 # I noticed in terminal "highlight file" won't do it (unknown file type)
112 # hightlight < file will do it, and it's online documentation
113 # suggests it reads shebang. Todo: file a bug for gitweb
114 # to make highlight read shebangs.
115 our \$projectroot = "$gitroot";
116 # not documented at https://git-scm.com/docs/gitweb.conf,
117 # but it's in the debian conf, so use it.
118 # directory to use for temp files.
119 our \$git_temp = "/tmp";
120 push @git_base_url_list, "https://$domain/git";
121 our @extra_breadcrumbs = (
122 [ '$domain' => '/' ],
124 our \$home_link_str = 'git';
125 our \$site_footer = '$PWD/_site/gitweb-footer.html';
126 push @stylesheets, "/css/gitweb-site.css";
127 our \$favicon = '/assets/favicon.png';
128 # default is 25, cuts off descriptions.
129 our \$projects_list_description_width = 40;
130 # a bit superflous since they are all me
131 our \$omit_owner = true;
132 # highlight scripts with no extension, uses a patch
133 # that is on it's way upstream.
134 our \$highlight_force = 1;
137 apache-site
- $domain <<EOF
138 # to run python script on my site:
139 <Directory /var/www/$domain/html/on2vote>
140 # to run python scripts with cgi
142 AddHandler cgi-script .py
145 <Directory "/var/www/$domain/html/cgi">
147 SetHandler cgi-script
150 # redirect some old paths when I was using jekyll.
151 Redirect permanent /10-14-2014/On2-vote-results.html /blog/on2-vote-results.html
152 Redirect permanent /09-29-2014/say-On2.html /blog/say-on2.html
153 Redirect permanent /08-07-2014/uninstalling-setup.html /blog/python-uninstall.html
154 Redirect permanent /08-01-2014/publising-my-technical-notes.html /blog/publishing-my-technical-notes.html
156 # All below is for gitweb + git-http-web.
157 # A simple builtin way to have a read only git website.
158 # I didn't find any significantly better alternatives out there.
159 SetEnv GIT_PROJECT_ROOT $gitroot
160 SetEnv GIT_HTTP_EXPORT_ALL
162 # note: cgi scripts can go anywhere into the filesystem,
163 # so there is no need to do a directory block for $gitroot
166 <Directory /usr/lib/git-core>
171 <Directory /usr/share/gitweb>
172 Options +FollowSymLinks +ExecCGI
173 AddHandler cgi-script .cgi
176 # from man-git-http-backend, so git-http-web ang gitweb can both be used.
177 # it is instead of this:
178 # #ScriptAlias / /usr/lib/git-core/git-http-backend/
180 "(?x)^/git/(.*/(HEAD | \\
182 objects/(info/[^/]+ | \\
183 [0-9a-f]{2}/[0-9a-f]{38} | \\
184 pack/pack-[0-9a-f]{40}\\.(pack|idx)) | \\
185 git-(upload|receive)-pack))\$" \\
186 /usr/lib/git-core/git-http-backend/\$1
190 # man-git-http-backend claims we should do this, but
191 # it causes no css/images to be displayed. Instead,
192 # just stick with the standard gitweb example directive
194 #ScriptAlias /git /usr/share/gitweb/gitweb.cgi/
195 Alias /git /usr/share/gitweb
200 $script_dir/gitweb-descriptions
$gitroot
203 $s rm -rf /var
/www
/$domain/html
204 $s ln -sT $script_dir/_site
/var
/www
/$domain/html