-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.sh
47 lines (37 loc) · 1.34 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
#
# If you using WSL, don't forget change:
#
# from: /var/spool/apt-mirror
# to: /mnt/d/apt-mirror
#
apt install -y curl git apt-mirror screen rsync htop nginx genisoimage
perl -pi -e 's#(.*sudo.*ALL=)(.*)#${1}(ALL) NOPASSWD:ALL#' /etc/sudoers
chmod +x /var/spool/apt-mirror/var/*.sh
touch /etc/apt/mirror.list ; nano $_
# Cron run every midnight
cat > /etc/cron.d/apt-mirror <<EOF
* 0 * * * /usr/bin/apt-mirror &>/var/log/apt-mirror.cron.log &
# @reboot /usr/bin/apt-mirror &>/var/log/apt-mirror.cron.log &
EOF
# Nginx virtualhost
cat > /etc/nginx/sites-available/default <<EOF
server {
listen 80 default_server;
server_name _;
index index.html;
autoindex on;
location / { try_files \$uri \$uri/ =404; }
location ~ /\.ht { deny all; }
root /var/spool/apt-mirror/mirror/;
location /ubuntu { alias /var/spool/apt-mirror/mirror/kartolo.sby.datautama.net.id/ubuntu; }
location /debian { alias /var/spool/apt-mirror/mirror/kartolo.sby.datautama.net.id/debian; }
location /debian-security { alias /var/spool/apt-mirror/mirror/kartolo.sby.datautama.net.id/debian-security; }
}
EOF
# Test running in background
nohup /usr/bin/apt-mirror &>/var/log/apt-mirror.log &
# Check disk usage
du -hsc /var/spool/apt-mirror/
# Crate iso image
genisoimage -v -r -V APTREPO -o apt-repo.iso /var/spool/apt-mirror/