Script to chroot MySQL on 32bit CentOS 5

# Set chroot location
/etc/init.d/mysqld stop

# Creating directory structure
mkdir -p $J/dev $J/etc $J/tmp $J/var/tmp $J/usr/libexec $J/usr/share/mysql/english \
  $J/usr/share/mysql/norwegian $J/var/run/mysqld $J/var/log $J/var/lib $J/bin $J/lib $J/var/run/nscd
chown -R root:sys $J
chmod -R 755 $J
chmod 1777 $J/tmp
# Copy necessary files
cp /usr/libexec/mysqld $J/usr/libexec/
cp /usr/share/mysql/english/errmsg.sys $J/usr/share/mysql/english/
cp /usr/share/mysql/norwegian/errmsg.sys $J/usr/share/mysql/norwegian/
cp -r /usr/share/mysql/charsets $J/usr/share/mysql/
cp /etc/hosts $J/etc/
cp /etc/host.conf $J/etc/
cp /etc/resolv.conf $J/etc/
cp /bin/bash $J/bin
grep mysql /etc/group > $J/etc/group
grep mysql /etc/passwd > $J/etc/passwd
cp /etc/my.cnf $J/etc/
cp -R /var/lib/mysql $J/var/lib/
chown -R mysql:mysql $J/var
cp /usr/lib/ /lib/ /lib/ /lib/ \
/lib/ /usr/lib/ /lib/ /lib/ /lib/ \
/lib/ /lib/ /usr/lib/ /lib/ /lib/ \
/usr/lib/ /lib/ /usr/lib/ /lib/ \
/usr/lib/ /lib/ /lib/ /lib/ $J/lib
cp /etc/ $J/etc
ln -s /var/run/nscd/socket $J/var/run/nscd/socket
# As with Apache, we need to create null device:
mknod $J/dev/null c 2 2
chown root:sys $J/dev/null
chmod 666 $J/dev/null


Popular posts from this blog

ActiveMQ, easy to use open source message oriented middleware (MOM)

Basic Send Message to MQ with Java and IBM MQ JMS

Apache Apollo