Created
May 29, 2022 17:33
-
-
Save ChatchaiJ/9dd8b0769824add3d248e5eede44608e to your computer and use it in GitHub Desktop.
Prepare debian system + apache2 server to be debian repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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