forked from teonet-co/teonet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_remote_download.sh
executable file
·60 lines (54 loc) · 1.13 KB
/
make_remote_download.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
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
#
# File: make_remote_download.sh
# Author: Kirill Scherba <kirill@scherba.ru>
#
# Upload (mirror) local repository to remote host
#
# Created on Aug 27, 2015, 2:08:45 AM
#
ANSI_BROWN="\033[22;33m"
ANSI_NONE="\033[0m"
REPO=../repo
# Parameters:
#
# @param $1 RPM_SUBTYPE: deb, rpm, yum, zyp (default: deb)
# @param $2 Install prefix: default: sudo apt-get install -y
#
# Check parameters
if [ -z "$1" ]; then
RPM_SUBTYPE="deb";
else
RPM_SUBTYPE=$1
fi
if [ -z "$2" ]; then
sudo apt-get install -y lftp
else
$2"lftp"
fi
if [ "$RPM_SUBTYPE" = "deb" ]; then
SUBFOLDER=ubuntu
else
if [ "$RPM_SUBTYPE" = "zyp" ]; then
SUBFOLDER=opensuse
else
SUBFOLDER=rhel
fi
fi
if [ ! -d "$REPO" ]; then
mkdir $REPO
if [ ! -d "$REPO/$SUBFOLDER" ]; then
mkdir $REPO/$SUBFOLDER
fi
fi
# Upload local repository to remote host
echo $ANSI_BROWN"Download remote host to local repository:"$ANSI_NONE
echo ""
lftp -c "
set ftp:list-options -a;
open ftp://$REPO_USER:$REPO_PASSWORD@repo2.ksproject.org;
lcd $REPO/$SUBFOLDER;
cd repo/$SUBFOLDER;
mirror --delete --use-cache --verbose --allow-chown
"
echo ""