forked from intel/virtual-storage-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepo
executable file
·111 lines (98 loc) · 3 KB
/
repo
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
function __create_repo_by_rpms() {
sudo yum install -y createrepo
local old_dir=`pwd`
cd $TOPDIR/
mkdir -p /tmp/debs/
find . -name "*.rpm" | grep "vsm-" | xargs -i rm -rf {}
find /var -name "*.rpm" | grep vsm | xargs -i rm -rf {}
find . -name "*.rpm" | grep "vsmclient" | xargs -i rm -rf {}
mkdir -p $TOPDIR/vsmrepo
find ~/rpmbuild/RPMS -name "*.rpm" | grep vsm | xargs -i cp -rf {} $TOPDIR/vsmrepo/
rm -rf $TOPDIR/vsmrepo/repodata
cd $TOPDIR/vsmrepo
createrepo .
cd $old_dir
}
function setup_http() {
mkdir -p /etc/yum.repos.d/saved
if [[ `ls /etc/yum.repos.d/ | grep repo | wc -l` -gt 0 ]]; then
cp -rf /etc/yum.repos.d/*.repo /etc/yum.repos.d/saved
rm -rf /etc/yum.repos.d/*.repo
fi
cat <<"__EOF__" > /etc/yum.repos.d/vsmrepo.repo
[vsmrepo]
name=vsmrepo
baseurl=file://%TOPDIR%/vsmrepo/
gpgcheck=0
enabled=1
proxy=_none_
__EOF__
sed -i "s,%TOPDIR%,$TOPDIR,g" /etc/yum.repos.d/vsmrepo.repo
echo $TOPDIR
cat /etc/yum.repos.d/vsmrepo.repo
cnt=`rpm -qa | grep httpd | wc -l`
if [[ $cnt -eq 0 ]]; then
yum install -y httpd
fi
cnt=`rpm -qa | grep httpd | wc -l`
if [[ ! $cnt -eq 2 ]]; then
echo "************ERROR***********"
echo "Have not find httpd package."
echo "Do you install it by yum."
echo "Check yum configuration."
exit 0
fi
service httpd restart
echo "" > /etc/httpd/conf.d/welcome.conf
# If enabled selinux
if [[ `sestatus | grep disa | wc -l` -eq 0 ]]; then
chcon -R -h -t httpd_sys_content_t /var/www/html/
setsebool -P httpd_can_network_connect 1 &
else
echo "Error Error selinux shutdown."
echo "Error Error selinux shutdown."
echo "Error Error selinux shutdown."
fi
chmod -R a+r /var/www/html/
iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT
}
function setup_yum_repo() {
local vsm_files=$TOPDIR/vsmrepo
if [[ ! -e $vsm_files ]]; then
vsm_files=$TOPDIR/vsmrepo
if [[ ! -e $vsm_files ]]; then
echo "************ERROR***********"
echo "Can not find Vsm Yum Repo dir."
echo "Please create it by:"
exit 0
fi
fi
[[ -e /var/www/html ]] && rm -rf /var/www/html/vsmrepo
cp -rf $vsm_files /var/www/html/
if [[ `sestatus | grep disa | wc -l` -eq 0 ]]; then
chcon -R -h -t httpd_sys_content_t /var/www/html/
fi
chmod -R a+r /var/www/html/
mkdir -p ~/repo
if [[ `ls /etc/yum.repos.d/ | grep repo | wc -l` -gt 0 ]]; then
cp -rf /etc/yum.repos.d/*.repo ~/repo
rm -rf /etc/yum.repos.d/*.repo
fi
cat <<"__EOF__" > /etc/yum.repos.d/vsmrepo.repo
[vsmrepo]
name=vsmrepo
baseurl=http://%REPO_HOST%/vsmrepo/
gpgcheck=0
enabled=1
proxy=_none_
__EOF__
sed -i "s,%REPO_HOST%,$REPO_HOST,g" /etc/yum.repos.d/vsmrepo.repo
echo $REPO_HOST
cat /etc/yum.repos.d/vsmrepo.repo
sudo yum clean all
sudo yum makecache
}
function setup_repo() {
setup_http
setup_yum_repo
}