3 CACHEDIR="/var/cache/yum" # where yum caches stuff -- is created as a subdir
4 # of the destination chroot
6 # FIXME perhaps after installation the script can modify the target machine's yum config to point to our Squid proxy
7 # or define http_proxy inside the machine. that would make upgrades for customers much much faster.
8 # better idea: instead of using a web cache, use a stash on the machine, we rsync the new RPMs into it once it's finished
9 # we would need a mutex (flock or fcntl based?) that mutially excludes the critical section
10 # the critical section is both the yum and the rsync process
11 # we also need to rsync packages from the stash into the var cache on the vps, and a mutex to lock out if another yum is running, just as in the first scenario
12 # cannot use a symlink because its chrooted for the duration of the process
13 # at any case, the repo names for different distros need to be different, otherwise the caches will clash horribly
14 # FIXME once that is done, we can stop using apt-proxy or apt-cacher
15 # FIXME try to make it for suse, mandriva or any other rpm-based distro
17 YUMENVIRON="$1" # where the yum config is generated and deployed
18 INSTALLROOT="$2" # destination directory / chroot for installation
20 if [ "${INSTALLROOT}" = "" -o ! -d "${INSTALLROOT}" -o "${YUMENVIRON}" = "" ] ; then
21 echo "usage: centos-installer /yum/environment (will be created) /destination/directory (must exist)"
22 echo "dest dir MUST BE an absolute path"
29 which rpm >/dev/null 2>&1 || { echo "rpm is not installed. please install rpm." ; exit 124 ; }
31 # sometimes when the RPM database is inconsistent, yum fails but exits with success status
32 # we make sure the db is in good health
41 if [ "${ARCH}" = x86_64 ] ; then
42 exclude="*.i386 *.i586 *.i686"
44 elif [ "${ARCH}" = i686 ] ; then
48 echo "Unknown architecture: ${ARCH} -- stopping centos-installer"
52 # make yum environment
54 mkdir -p ${YUMENVIRON}/pluginconf.d ${YUMENVIRON}/repos.d ${CACHEDIR} ${INSTALLROOT}/var/log
56 # In case the folder is not there:
61 cat > "${YUMENVIRON}/yum.conf" << EOF
63 reposdir=$YUMENVIRON/repos.d
64 pluginconfpath=$YUMENVIRON/pluginconf.d
66 installroot=$INSTALLROOT
72 distroverpkg=centos-release
81 cat > "${YUMENVIRON}/pluginconf.d/installonlyn.conf" << EOF
87 cat > "${YUMENVIRON}/repos.d/CentOS-Base.repo" << EOF
90 #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
91 mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
93 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
96 name=CentOS-6 - Updates
97 #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
98 mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
100 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
103 name=CentOS-6 - Extras
104 #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
105 mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
107 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
111 #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
112 mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
114 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
120 exec yum -c "${YUMENVIRON}/yum.conf" -y install coreutils basesystem centos-release yum-basearchonly initscripts upstart nano nano yum wget which passwd joe screen