This article will describe installing Trac which manages user with digest authentication.
Table of Contents
1 Install Trac
The following script will install Trac and create "test" project.
- Login to Trac via digest authentication.
- ADMIN_PASSWD is password of admin user for digest authentication.
- USER_NAME is user name of not admin user for digest authentication.
- USER_PASSWD is password name of not admin user for digest authentication.
#!/bin/sh -e [ -z "${ADMIN_PASSWD}" ] && ADMIN_PASSWD="admin_passwd" [ -z "${USER_NAME}" ] && USER_NAME="guest" [ -z "${USER_PASSWD}" ] && USER_PASSWD="guest_passwd" apache_install() { # mod_wsgi2 supports python 2.7 which is used by trac. sudo pacman -Sy --noconfirm apache mod_wsgi2 sudo systemctl enable httpd # ssl configuration. # Country Name (2 letter code) [AU]: # State or Province Name (full name) [Some-State]: # Locality Name (eg, city) []: # Organization Name (eg, company) [Internet Widgits Pty Ltd]: # Organizational Unit Name (eg, section) []: # Common Name (e.g. server FQDN or YOUR name) []: # Email Address []: cat <<EOF | sudo openssl req -new -x509 -nodes -newkey rsa:4096 -days 1095 \ -keyout /etc/httpd/conf/server.key \ -out /etc/httpd/conf/server.crt AU Some-State city company section EOF sudo sed -i /etc/httpd/conf/httpd.conf \ -e 's/^#LoadModule ssl_module/LoadModule ssl_module/g' \ -e 's/^#LoadModule socache_shmcb_module/LoadModule socache_shmcb_module/g' cat <<EOF | sudo tee -a /etc/httpd/conf/httpd.conf Include conf/extra/httpd-ssl.conf EOF # rewrite configuration. sudo sed -i /etc/httpd/conf/httpd.conf \ -e 's/^#LoadModule rewrite_module/LoadModule rewrite_module/g' cat << EOF | sudo tee /etc/httpd/conf/extra/redirect-to-https.conf RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} EOF cat <<EOF | sudo tee -a /etc/httpd/conf/httpd.conf Include conf/extra/redirect-to-https.conf EOF # digest configuration. sudo sed -i /etc/httpd/conf/httpd.conf \ -e 's/#LoadModule auth_digest_module/LoadModule auth_digest_module/g' # wsgi configuration. cat <<EOF | sudo tee -a /etc/httpd/conf/httpd.conf LoadModule wsgi_module modules/mod_wsgi.so EOF sudo systemctl restart httpd } trac_install() { sudo pacman -Sy --noconfirm git base-devel git clone https://aur.archlinux.org/trac.git cd trac makepkg -s --noconfirm sudo pacman -U --noconfirm ./*.pkg.tar.xz cd .. rm -rf trac sudo mkdir /var/lib/trac sudo mkdir /srv/http/trac sudo chown http:http /srv/http/trac } create_project() { proj=$1 sudo trac-admin /var/lib/trac/"${proj}" initenv "${proj}" sqlite:db/trac.db sudo trac-admin /var/lib/trac/"${proj}" deploy /srv/http/trac/"${proj}" sudo chown -R http:http /var/lib/trac/"${proj}" sudo chown -R http:http /srv/http/trac/"${proj}" sudo pacman -Sy --noconfirm expect expect -c " set timeout -1 spawn sudo htdigest -c /var/lib/trac/${proj}/.htdigest ${proj} admin expect \"New password: \" send \"${ADMIN_PASSWD}\n\" expect \"Re-type new password: \" send \"${ADMIN_PASSWD}\n\" expect eof " sudo trac-admin /var/lib/trac/"${proj}" permission add admin TRAC_ADMIN expect -c " set timeout -1 spawn sudo htdigest /var/lib/trac/${proj}/.htdigest ${proj} ${USER_NAME} expect \"New password: \" send \"${USER_PASSWD}\n\" expect \"Re-type new password: \" send \"${USER_PASSWD}\n\" expect eof " cat <<EOF | sudo tee /etc/httpd/conf/extra/"${proj}".conf WSGIScriptAlias /trac/${proj} /srv/http/trac/${proj}/cgi-bin/trac.wsgi <Location /trac/${proj}> AuthType Digest AuthName "${proj}" AuthUserFile /var/lib/trac/${proj}/.htdigest Require valid-user </Location> EOF cat <<EOF | sudo tee -a /etc/httpd/conf/httpd.conf Include conf/extra/${proj}.conf EOF sudo systemctl restart httpd } trac_main() { apache_install trac_install create_project test create_project OtherProject } trac_main