Home | Back


Script สำหรับการดาวน์โหลด Package เพื่อสร้าง Repository ส่วนตัวของ Arch Linux

Tuesday, 9 December 2014



ผมได้สร้าง Script สำหรับการดาวน์โหลด Package ต่าง ๆ เพื่อสร้าง Repository ส่วนตัวของ Arch Linux โดยจะมี ทั้งหมด 3 Repository คือ Core, Extra, Community โดยการใช้งานจะเรียกผ่าน Cron โดยอาจจะให้ทำงานทุก 3-4 ชั่วโมง โดยไฟล์ทั้งสามมีดังนี้ครับ

File : repo-core.sh

#!/bin/bash

SOURCE='rsync://mirror.us.leaseweb.net/archlinux'
DEST='/home/authapon/web/archlinux'
REPOS='core'
RSYNC_OPTS="-qarulpEot  --delete-after --delete-excluded --delay-updates"
LCK_FLE='/home/authapon/web/repo-core.lck'

PATH='/usr/bin'

# Make sure only 1 instance runs
if [ -e "$LCK_FLE" ] ; then
 OTHER_PID=$(cat $LCK_FLE)
 echo "Another instance already running: $OTHER_PID"
 exit 1
fi
echo $$ > "$LCK_FLE"

echo "Syncing $REPO"
rsync $RSYNC_OPTS ${SOURCE}/${REPO} ${DEST}

# Cleanup
rm -f "$LCK_FLE"

exit 0

File : repo-extra.sh

#!/bin/bash

SOURCE='rsync://mirror.us.leaseweb.net/archlinux'
DEST='/home/authapon/web/archlinux'
REPOS='extra'
RSYNC_OPTS="-qarulpEot  --delete-after --delete-excluded --delay-updates"
LCK_FLE='/home/authapon/web/repo-extra.lck'

PATH='/usr/bin'

# Make sure only 1 instance runs
if [ -e "$LCK_FLE" ] ; then
 OTHER_PID=$(cat $LCK_FLE)
 echo "Another instance already running: $OTHER_PID"
 exit 1
fi
echo $$ > "$LCK_FLE"

echo "Syncing $REPO"
rsync $RSYNC_OPTS ${SOURCE}/${REPO} ${DEST}

# Cleanup
rm -f "$LCK_FLE"

exit 0

File : repo-community.sh

#!/bin/bash

SOURCE='rsync://mirror.us.leaseweb.net/archlinux'
DEST='/home/authapon/web/archlinux'
REPOS='community'
RSYNC_OPTS="-qarulpEot  --delete-after --delete-excluded --delay-updates"
LCK_FLE='/home/authapon/web/repo-community.lck'

PATH='/usr/bin'

# Make sure only 1 instance runs
if [ -e "$LCK_FLE" ] ; then
 OTHER_PID=$(cat $LCK_FLE)
 echo "Another instance already running: $OTHER_PID"
 exit 1
fi
echo $$ > "$LCK_FLE"

echo "Syncing $REPO"
rsync $RSYNC_OPTS ${SOURCE}/${REPO} ${DEST}

# Cleanup
rm -f "$LCK_FLE"

exit 0


Home | Back