Kerala Cyber Warriors
KCW Uploader V1.1

Path : /var/lib/dpkg/info/
File Upload :
Current File : //var/lib/dpkg/info/cpanel-phpmyadmin.preinst

#!/bin/sh

set -e

## <asset scriplets/pre>


set -e

USER=cpanelphpmyadmin
GROUP=$USER
CPMA=/var/cpanel/userhomes/cpanelphpmyadmin

PREFIX_BASE=/usr/local/cpanel/base/3rdparty
PREFIX=${PREFIX_BASE}/phpMyAdmin

checkPerms() {
    echo "check $USER user and directories permissions"

    # add group
    /usr/bin/getent group $GROUP >/dev/null || /usr/sbin/groupadd -r $GROUP

    # add user if needed
    /usr/bin/getent passwd $USER >/dev/null || \
    /usr/sbin/useradd -r -g $GROUP -M -d /var/cpanel/userhomes/$USER \
        -s /usr/local/cpanel/bin/noshell \
        -c "phpMyAdmin for cPanel & WHM" $USER

    # ensure directories, perms & ownership
    #`  required for Ubuntu, not necessary for CentOS
    /bin/mkdir -p $CPMA
    chmod 711 $CPMA
    chown $GROUP:$USER $CPMA

    /bin/mkdir -p $CPMA/cache
    chmod 700 $CPMA/cache
    chown $GROUP:$USER $CPMA/cache

    /bin/mkdir -p $CPMA/mail
    chmod 711 $CPMA/mail
    chown $GROUP:$USER $CPMA/mail

    /bin/mkdir -p $CPMA/sessions
    chmod 700 $CPMA/sessions
    chown $GROUP:$USER $CPMA/sessions

    /bin/mkdir -p $CPMA/tmp
    chmod 700 $CPMA/tmp
    chown $GROUP:$USER $CPMA/tmp

}

runPre_cleanup() {
  echo "cleaning up old phpmyadmin before installing new one."
  echo "We only do this the first time we install the cpanel-phpmyadmin package"
  if [ -f ${PREFIX}/config.sample.inc.php ] ; then
    cp -f ${PREFIX}/config.sample.inc.php ${PREFIX_BASE}
  fi
  if [ -f ${PREFIX}/config.inc.php ] ; then
    cp -f ${PREFIX}/config.inc.php ${PREFIX_BASE}
  fi
  /bin/rm -rf ${PREFIX} ||:
  mkdir -p ${PREFIX}
  if [ -f ${PREFIX_BASE}/config.sample.inc.php ] ; then
    mv -f ${PREFIX_BASE}/config.sample.inc.php ${PREFIX}/
  fi
  if [ -f ${PREFIX_BASE}/config.inc.php ] ; then
    mv -f ${PREFIX_BASE}/config.inc.php ${PREFIX}/
  fi
}

# main entrance
runPre_install() {
    runPre_cleanup;
    checkPerms;
}

runPre_upgrade() {
    checkPerms;
}

## </asset>


case "$1" in
  install)
    runPre_install;
    ;;
  upgrade)
    runPre_upgrade;
    ;;
esac

exit 0

-=[ KCW uplo4d3r c0ded by cJ_n4p573r ]=-
Ⓒ2017 ҠЄГѦLѦ СүѣЄГ ЩѦГГіѺГՏ