본문 바로가기

Operating Systems/Linux

[ Linux ] APT 패키지 관리자 서버 설치

[ APT 패키지 관리자 서버 ]

# repository 폴더 생성
mkdir -p /app/repo

# http를 통하여 레포지토리를 사용할 수 있도록 설정
apt-get install -y apache2
systemctl enable apache2

# apache repo 경로 추가
cat <<ADD_REPO_SETTING >> /etc/apache2/apache2.conf

# apt repository server configuration
Alias /repo "/app/repo"

<Directory "/app/repo">
        Options FollowSymLinks
        DirectoryIndex index.html index.htm index.jsp *.jsp *.php
        Order allow,deny
        Allow from all
        Require all granted
</Directory>
ADD_REPO_SETTING

# repository 저장소 생성을 위한 패키지 압축 도구 설치
apt-get -y install dpkg-dev

# 레포지토리 경로에 패키지 다운로드 스크립트 생성
mkdir -p /app/script/

cat <<APT_LOCAL_INSTALL > /app/script/lapt.sh && chmod 755 /app/script/lapt.sh
#!/bin/bash

apt-get -y install -d -o=dir::cache=/app/repo \$1

apt-get -y install -d --reinstall -o=dir::cache=/app/repo \$1

apt-cache show \$1 | grep -E "Depends|Recommends|Suggests|Pre-Depends" | sed "s/,/\n/g" | sed -e "s/Depends://g" -e "s/Recommends://g" -e "s/Suggests://g" -e "s/Pre-Depends://g" | awk -F "(" '{print \$1}' | xargs apt-get -y install -d -o=dir::cache=/app/repo 

apt-cache show \$1 | grep -E "Depends|Recommends|Suggests|Pre-Depends" | sed "s/,/\n/g" | sed -e "s/Depends://g" -e "s/Recommends://g" -e "s/Suggests://g" -e "s/Pre-Depends://g" | awk -F "(" '{print \$1}' | xargs apt-get -y reinstall -d -o=dir::cache=/app/repo

mv /app/repo/archives/*.deb /app/repo

rm -r /app/repo/archives /app/repo/*.bin

cd /app/repo

dpkg-scanpackages . /dev/null | gzip -9c > /app/repo/Packages.gz

apt-get update

APT_LOCAL_INSTALL

/app/script/lapt.sh vsftpd

# 기존 레포지토리 정보 삭제/백업
mkdir /etc/apt/backup
mv -b /etc/apt/sources.list /etc/apt/backup

cat <<SET_REPO_SETTING > /etc/apt/sources.list
deb [trusted=yes] file:/app/repo ./
SET_REPO_SETTING

# 레포지토리 정보 업데이트
apt-get update

# 로컬 테스트
apt-get install vsftpd

# repo 배포용 아파치 서버 재시작
systemctl restart apache2

# 방화벽 종료
ufw disable

 

[ 클라이언트 ]

# 기존 레포지토리 정보 삭제/백업
mkdir /etc/apt/backup
mv -b /etc/apt/sources.list /etc/apt/backup

cat <<SET_REPO_SETTING > /etc/apt/sources.list
deb [trusted=yes] http://192.168.108.20/repo/ ./
SET_REPO_SETTING

# 레포지토리 캐쉬 등 삭제
apt-get update

apt-get install vsftpd

'Operating Systems > Linux' 카테고리의 다른 글

[ Linux ] MAIL 서버 설치  (0) 2021.07.24
[ Linux ] LDAP 서버 설치  (0) 2021.07.20
[ Linux ] 고정 아이피 설정  (0) 2021.07.11
[ Linux ] DNS 서버 설치  (0) 2021.07.11
[ Linux ] YUM 패키지 관리자 서버 설치  (0) 2021.06.30