Roman

Roman

С нами с 21 августа 2017; Место в рейтинге пользователей: #130
Роман Садоян
28 сентября 2016, 18:55
1
+1
Пользуйся, только осторожно!
Добавил: При восстановлении конфигов — очищает /core/cache
#!/bin/bash

USER=$1
if [ "$USER" == "" ];
then
USER=$(getent passwd $UID | sed -e 's/\:.*//')
fi

# Home directory
HOME=$(getent passwd $USER)
HOME=${HOME#*:/}
HOME='/'$(echo $HOME | cut -f1 -d:)
# Site directory
SDIR=$HOME'/www'
# Backup directory
BDIR=$HOME'/config_backup'

echo 'Running for user "'$USER'"'
echo "Enter mode (1 - backup config; 2 - restore config; 0 - exit):"
read MODE

if [ "$MODE" == "1" ];
then
    if ! [ -d $BDIR ]; then
    echo 'Backup directory '$BDIR' is not exists. Creating'
    mkdir $BDIR
    fi
cp $SDIR/connectors/config.core.php $BDIR
cp $SDIR/core/config/config.inc.php $BDIR
chown -R $USER:$USER $BDIR
echo "Done."
elif [ "$MODE" == "2" ];
then
cp $BDIR/config.core.php $SDIR
cp $BDIR/config.core.php $SDIR/connectors
cp $BDIR/config.core.php $SDIR/manager
cp $BDIR/config.inc.php $SDIR/core/config
chown $USER:$USER $SDIR/config.core.php
chown $USER:$USER $SDIR/connectors/config.core.php
chown $USER:$USER $SDIR/manager/config.core.php
chown $USER:$USER $SDIR/core/config/config.inc.php
rm -rf $SDIR/core/cache/
echo "Done."
elif [ "$MODE" == "0" ];
then
exit;
else
echo "Unknown MODE. Do nothing. Exit."
exit;
fi