Setup CentOS6/7 Local Repository

For speeding up the deployment, I have to setup the local repository for CentOS6/7, following is the steps for setting up such two repositories.
The steps are followed by following URL:
https://support.opennodecloud.com/wiki/doku.php?id=usrdoc:os:repomirror

# cd /etc/yum.repos.d/
# curl -O https://copr.fedoraproject.org/coprs/baurzhanm/mrepo/repo/epel-6/baurzhanm-mrepo-epel-6.repo
# vim baurzhanm-mrepo-epel-6.repo
# yum update
# yum -y install screen lftp httpd mrepo
# vim mrepo.conf
    ### Configuration file for mrepo
    
    ### The [main] section allows to override mrepo's default settings
    ### The mrepo-example.conf gives an overview of all the possible settings
    [main]
    srcdir = /var/mrepo
    wwwdir = /var/www/mrepo
    confdir = /etc/mrepo.conf.d
    arch = x86_64
    
    mailto = root@localhost
    smtp-server = localhost
    
    #rhnlogin = username:password
    
    ### Any other section is considered a definition for a distribution
    ### You can put distribution sections in /etc/mrepo.conf.d/
    ### Examples can be found in the documentation at:
    ###     /usr/share/doc/mrepo-0.8.9/dists/.

Add the configuration files for CentOS 6:

# vim  /etc/mrepo.conf.d/centos6.conf
[centos6]
name = CentOS $release ($arch)
release = 6
arch = x86_64
metadata = yum repomd

#iso = http://mirrors.aliyun.com/centos/$release/isos/$arch/CentOS-6.6-x86_64-bin-DVD?.iso
#os = http://mirrors.aliyun.com/centos/$release/os/$arch/Packages/ 
#updates = http://mirrors.aliyun.com/centos/$release/updates/$arch/Packages/
extras = http://mirrors.aliyun.com/centos/$release/extras/$arch/Packages/
epel = http://mirrors.aliyun.com/epel/$release/$arch/

Add configuraiton files for CentOS 7:

# vim  /etc/mrepo.conf.d/centos7.conf
[centos7]
name = CentOS $release ($arch)
release = 7
arch = x86_64
metadata = yum repomd

#iso = http://mirrors.aliyun.com/centos/$release/isos/$arch/CentOS-7.0-1406-x86_64-DVD.iso
#os = http://mirrors.aliyun.com/centos/$release/os/$arch/Packages/ 
#updates = http://mirrors.aliyun.com/centos/$release/updates/$arch/Packages/
#epel = http://mirrors.aliyun.com/epel/$release/$arch/
extra=http://mirrors.aliyun.com/centos/$release/extras/$arch/Packages/

Use following comands for initial sync, it will take a very~long~long~long time.

# mrepo -g -u -vvv [centos6|centos7]

After syncing, add definition into the apache’s configuration:

# vi /etc/httpd/conf.d/mrepo.conf
--- ADD ---
AddDescription "CentOS 6 for x86" centos6-i386
AddDescription "CentOS 6 for x86_64" centos6-x86_64
AddDescription "CentOS 7 for x86" centos7-i386
AddDescription "CentOS 7 for x86_64" centos7-x86_64
--- ADD ---
# Add repofile for CentOS 6 mirror
cat << 'EOF' > /var/www/mrepo/centos6-x86_64/CentOS-local-http.repo 
#
# CentOS-local-http.repo
#
 
[0-base]
name=CentOS-local-base
baseurl=http://mirror.local.int/mrepo/centos6-x86_64/RPMS.os/
gpgcheck=0
 
[0-updates]
name=CentOS-local-updates
baseurl=http://mirror.local.int/mrepo/centos6-x86_64/RPMS.updates/
gpgcheck=0
EOF
 
# Add repofile for CentOS 7 mirror
cat << 'EOF' > /var/www/mrepo/centos7-x86_64/CentOS-local-http.repo 
#
# CentOS-local-http.repo
#
 
[0-base]
name=CentOS-local-base
baseurl=http://mirror.local.int/mrepo/centos7-x86_64/RPMS.os/
gpgcheck=0
 
[0-updates]
name=CentOS-local-updates
baseurl=http://mirror.local.int/mrepo/centos7-x86_64/RPMS.updates/
gpgcheck=0
EOF
 
# chkconfig httpd on
# service httpd restart

mrepo for CentOS6.5

[root:/home/juju/mrepo]# cat /etc/mrepo.conf.d/centos6.5.conf  
### URL: http://www.centos.org/
 
[centos6.5]
name = CentOS $release ($arch)
release = 6.5
arch = x86_64
metadata = yum repomd

os=http://vault.centos.org/$release/os/$arch/Packages/
updates=http://vault.centos.org/$release/updates/$arch/Packages/
extras=http://vault.centos.org/$release/extras/$arch/Packages/
centosplus=http://vault.centos.org/$release/centosplus/$arch/Packages/
fasttrack=http://vault.centos.org/$release/fasttrack/$arch/Packages/

sync the repository via:

# mrepo -g -u -vvv centos6.5

Setup Local Repository

Ubuntu

After using apt-mirror syncing all of the packages from the repository website, setup a ftp site:

# apt-get install -y proftpd
# cat conf.d/anonymous.conf 
<Anonymous ~ftp>
   User                    ftp
   Group                nogroup
   UserAlias         anonymous ftp
   RequireValidShell        off
#   MaxClients                   10
   <Directory *>
     <Limit WRITE>
       DenyAll
     </Limit>
   </Directory>
 </Anonymous>
#  mount --bind /mnt/myrepo/mirror/mirrors.aliyun.com/ /srv/ftp/
# service proftpd restart

Now Open your browser to ftp://Your_URL/, you will find the repository available.

CentOS Proftpd

Just remember the default directory is located at /var/ftp,

# yum install -y proftpd
# mount --bind /mirror/mirrors.aliyun.com/ /var/ftp/
# service proftpd restart

Client Configuration

Replace the URL into your ftp url:

# vim /etc/apt/sources.list
deb ftp://YourURL/ubuntu/ trusty main restricted universe multiverse
deb ftp://YourURL/ubuntu/ trusty-security main restricted universe multiverse
deb ftp://YourURL/ubuntu/ trusty-updates main restricted universe multiverse
deb ftp://YourURL/ubuntu/ trusty-proposed main restricted universe multiverse
deb ftp://YourURL/ubuntu/ trusty-backports main restricted universe multiverse
deb-src ftp://YourURL/ubuntu/ trusty main restricted universe multiverse
deb-src ftp://YourURL/ubuntu/ trusty-security main restricted universe multiverse
deb-src ftp://YourURL/ubuntu/ trusty-updates main restricted universe multiverse
deb-src ftp://YourURL/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src ftp://YourURL/ubuntu/ trusty-backports main restricted universe multiverse
# apt-get update && apt-get upgrade 

Using local repository will greately improve your development speed.

Use apache way(On CentOS6.6)

By using the symlinks and enable the httpd to start automatically at systemboot.

[root:/var/www]# cd html/
[root:/var/www/html]# ln /home/juju/myrepo/mirror/mirrors.aliyun.com/ubuntu -s
[root:/var/www/html]# chkconfig httpd on

My Configuration On Cobbler For Deploying Ubuntu12.04

Configuration file for preseed, put it under: /var/lib/cobbler/kickstarts/autoinstall.seed:

# BASIC
d-i  debian-installer/locale    string en_US.UTF-8
d-i  debian-installer/splash    boolean false
d-i  console-setup/ask_detect   boolean false
d-i  console-setup/layoutcode   string us
d-i  console-setup/variantcode  string
d-i  clock-setup/utc            boolean true
d-i  clock-setup/ntp            boolean true

# DISKPART
d-i  partman-auto/method                string regular
d-i  partman-lvm/device_remove_lvm      boolean true
d-i  partman-lvm/confirm                boolean true
d-i  partman/confirm_write_new_label    boolean true
d-i  partman/choose_partition           select Finish partitioning and write changes to disk
d-i  partman/confirm                    boolean true
d-i  partman/confirm_nooverwrite        boolean true
d-i  partman/default_filesystem         string ext3

# SOFTWARE
# /var/www/cobbler/ks_mirror/Ubuntu12.04-x86_64/ubuntu/
d-i  mirror/country             string manual
d-i  mirror/http/hostname       string $http_server
d-i  mirror/http/directory      string /cobbler/ks_mirror/Ubuntu12.04-x86_64/ubuntu
d-i  mirror/http/proxy          string
d-i  apt-setup/security_host    string $http_server
d-i  apt-setup/security_path    string /cobbler/ks_mirror/Ubuntu12.04-x86_64/ubuntu
d-i  apt-setup/services-select  multiselect none
d-i  pkgsel/upgrade             select none
d-i  pkgsel/language-packs      multiselect
d-i  pkgsel/update-policy       select none
d-i  pkgsel/updatedb            boolean true
d-i  pkgsel/include             string openssh-server

# USER
d-i  passwd/root-login                  boolean true
d-i  passwd/make-user                   boolean false
d-i  passwd/root-password               password root
d-i  passwd/root-password-again         password root
d-i  user-setup/allow-password-weak     boolean true

# FINISH
d-i  grub-installer/skip                boolean false
d-i  lilo-installer/skip                boolean false
d-i  grub-installer/only_debian         boolean true
d-i  grub-installer/with_other_os       boolean true
d-i  finish-install/keep-consoles       boolean false
d-i  finish-install/reboot_in_progress  note
d-i  cdrom-detect/eject                 boolean true
d-i  debian-installer/exit/halt         boolean false
d-i  debian-installer/exit/poweroff     boolean false

# EXTRA
d-i  preseed/late_command       string echo "UseDNS no" >> /target/etc/ssh/sshd_config

Edit the profile via:

$ cobbler profile list
$ cobbler profile edit --name=Ubuntu12.04-x86_64 --kickstart=/var/lib/cobbler/kickstarts/autoinstall.seed 

Now select the installation, your installation will use local repository.

Re-Orgnize Blog

Since my last blog touched something special, I have to delete the whole repository and re-orgnize the structure again. This time I also use Octopress, but the version has been upgraded to the 3.0, this article records the steps.

Github Account

Register a new account, and verrify the email, add your own ssh key, test it via ssh -T git@github.com

Repository

Get the latest repository via:

$ git clone https://github.com/imathis/octopress.git

Configuration of the konsole, enable the zsh -l at the login shell. Settings-> Edit Current Profile-> General -> Command(/bin/zsh -l)

$ rvm use 1.9.3
$ ruby --version
ruby 1.9.3p547 (2014-05-14 revision 45962) [x86_64-linux]
$ gem install bundler
$ vim Gemfile
#source "https://rubygems.org"
source "http://mirrors.aliyun.com/rubygems/"
$ bundle install
$ rake install

Now the basic configuration of the repository has been added.

Plugins

For adding videos:

$ git clone https://github.com/manojlds/octopress-plugins.git
$ cd octopress
$ cd plugins
$ cp ../../octopress-plugins/youtube.rb ./

Encryption

Setup A More intelligent OpenWRT Router

Openssh-Server

The default sshd is provided by dropbear, the functionality is not good, so I have to replace it with openssh-server.

root@OpenWrt:~# uci set dropbear.@dropbear[0].Port=2222
root@OpenWrt:~# uci commit dropbear
root@OpenWrt:~# /etc/init.d/dropbear restart
root@OpenWrt:~# opkg install openssh-server
root@OpenWrt:~# opkg install openssh-client

Configure the OpenSSH:

# /etc/init.d/sshd enable
# /etc/init.d/sshd start
# /etc/init.d/dropbear disable
# /etc/init.d/dropbear stop

The next time you login will ask you for changing your password, do it and continue for using ssh.

ShadowSocks and DNS

For ShadowSocks you could refer to my previous blogs.
DNS Server is for automatically analyze the dns in server, install it via:

$ sudo yum install dnsmasq

Configure it to another port rather than the default 53.

redsocks 翻墙