Skip to content

Commit 9c135d5

Browse files
committed
fixed some bugs
1 parent ab0ae3a commit 9c135d5

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

sync.sh

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1-
#!/bin/env bash
1+
#!/bin/bash
22

3+
OPTIONS="-rtlHqv --delete-after --delay-updates --safe-links"
4+
REPO="rsync://mirrors.kernel.org/$1"
5+
DEST="/media/mirror/$1"
6+
LCK_FLE="/var/lock/mirror/$1.lck"
7+
LOG_FLE="/var/log/mirror/$1.log"
8+
9+
# Check for arguments
310
if [ -z $1 ]; then
411
echo "Usage: sync.sh [DISTRO]"
512
exit 1
613
fi
714

8-
OPTIONS="-rtlHqv --delete-after --delay-updates --safe-links"
9-
REPO="rsync://mirrors.kernel.org/$1"
10-
DEST="/media/mirror/$1"
11-
LCK_FILE="/tmp/rsync-mirror-$1.lck"
12-
LOG_FILE="/tmp/log-$1.log"
13-
1415
# Make sure only 1 instance runs
15-
if [ -e "$LCK_FILE" ]; then
16-
OTHER_PID=`cat $LCK_FILE`
17-
echo "Another instance already running: $OTHER_PID"
16+
if [ -e "$LCK_FLE" ]; then
17+
OTHER_PID=`cat $LCK_FLE`
18+
echo "Another instance already running: $OTHER_PID" > $LOG_FLE
1819
exit 1
1920
fi
20-
echo $$ > "$LCK_FILE"
21+
echo $$ > "$LCK_FLE"
2122

2223
# Sync
23-
rsync $OPTIONS $REPO $DEST &> $LOG_FILE
24+
rsync $OPTIONS $REPO $DEST &> $LOG_FLE
2425

2526
# Cleanup
2627
rm -f "$LCK_FLE"

0 commit comments

Comments
 (0)