Script to chroot MySQL on 32bit CentOS 5

#!/bin/bash
# Set chroot location
J=/securesystem/mysql
/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/libkrb5.so.3 /lib/libdl.so.2 /lib/libc.so.6 /lib/ld-linux.so.2 \
/lib/librt.so.1 /usr/lib/libz.so.1 /lib/libssl.so.6 /lib/libcrypto.so.6 /lib/libpthread.so.0 \
/lib/libcrypt.so.1 /lib/libnsl.so.1 /usr/lib/libstdc++.so.6 /lib/libm.so.6 /lib/libgcc_s.so.1 \
/usr/lib/libgssapi_krb5.so.2 /lib/libcom_err.so.2 /usr/lib/libk5crypto.so.3 /lib/libresolv.so.2 \
/usr/lib/libkrb5support.so.0 /lib/libkeyutils.so.1 /lib/libselinux.so.1 /lib/libsepol.so.1 $J/lib
cp /etc/ld.so.cache $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

Comments

Popular posts from this blog

Basic Send Message to MQ with Java and IBM MQ JMS

Basic Receive Message to MQ with Java and IBM MQ JMS

Creating a simple Alert / Success Message with ASP.NET/VB using Bootstrap