Update setup.sh

This commit is contained in:
kongkrit 2020-01-02 16:08:27 +07:00 committed by GitHub
parent e1fccb39b4
commit 5b1b953009
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 36 deletions

View File

@ -1,47 +1,29 @@
#!/bin/bash #!/bin/bash
function create_link {
# parse mirror.list to share under /var/www/package path
grep '^deb' /etc/apt/mirror.list | awk '{print $2}' | while IFS= read -r line
do
local mirror_path=
mirror_path=$(echo "$line" | sed -e 's|^ftp||' -e 's|^https\?||' -e 's|^rsync||' -e 's|://||' -e 's|/$||')
local target="/var/www/package"
local dest= echo "configuring /etc/apt/mirror.list"
case "$line" in echo "#### config ####
*ubuntu*) set base_path /var/www/html/ubuntu
dest="$target/ubuntu" set nthreads 20
;; set _tilde 0
*debian*)
dest="$target/debian"
;;
esac
if [ ! -h "$dest" ] && [ x"$dest" != x"" ]; then
echo "[$(date)] Create $dest"
ln -s "/var/spool/apt-mirror/mirror/$mirror_path" "$dest"
fi
done
}
# To setup http server config at first time deb $MIRROR_URL bionic main restricted universe multiverse
if [ ! -d /var/www/package ]; then deb $MIRROR_URL bionic-updates main restricted universe multiverse
mkdir -p /var/www/package deb $MIRROR_URL bionic-backports main restricted universe multiverse
sed -i '12s|DocumentRoot /var/www/html|DocumentRoot /var/www/package|' /etc/apache2/sites-enabled/000-default.conf deb $MIRROR_URL bionic-security main restricted universe multiverse
# If user doesn't provide mirror.list, using default setting clean http://archive.ubuntu.com/ubuntu" \
if [ ! -e /etc/apt/mirror.list ]; then > /etc/apt/mirror.list
echo "[$(date)] Using default mirror.list" echo "content of /etc/apt/mirror.list is..."
ln -s /mirror.list /etc/apt/mirror.list echo "-------------------------------------"
fi cat /etc/apt/mirror.list
create_link echo "-------------------------------------"
fi
# Apache gets grumpy about PID files pre-existing
rm -f /var/run/apache2/apache2.pid rm -f /var/run/apache2/apache2.pid
echo "starting apache server"
echo "[$(date)] Starting apache server"
service apache2 start service apache2 start
echo "apache started..."
while true; do while true; do
echo "[$(date)] Starting apt-mirror" echo "[$(date)] Starting apt-mirror"
apt-mirror apt-mirror