Skip to content

Instantly share code, notes, and snippets.

@ChatchaiJ
Created May 29, 2022 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChatchaiJ/9dd8b0769824add3d248e5eede44608e to your computer and use it in GitHub Desktop.
Save ChatchaiJ/9dd8b0769824add3d248e5eede44608e to your computer and use it in GitHub Desktop.
Prepare debian system + apache2 server to be debian repository
#!/bin/sh
REPODIR="/srv/repos/apt/debian"
CONF="/tmp/repos-$$.conf"
APACHECONFDIR="/etc/apache2/conf-available"
[ ! -d "${APACHECONFDIR}" ] && \
echo "Apache2 conf directory is not available, is it installed?" && \
exit
[ ! -d "${REPODIR}" ] && sudo mkdir -p ${REPODIR}
cat <<EOT > $CONF
# /etc/apache2/conf-available/repos.conf
Alias /debian $REPODIR
<Directory /srv/repos/ >
# We want the user to be able to browse the directory manually
Options Indexes FollowSymLinks Multiviews
Require all granted
</Directory>
<Directory "${REPODIR}/db/">
Require all denied
</Directory>
<Directory "${REPODIR}/conf/">
Require all denied
</Directory>
<Directory "${REPODIR}/incoming/">
Require all denied
</Directory>
EOT
sudo mv -f $CONF /etc/apache2/conf-available/repos.conf
sudo a2enconf repos
sudo apachectl configtest || { echo "apache configtest failed"; exit; }
sudo service apache2 reload
sudo ufw allow http
sudo ufw allow https
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment