#!/bin/bash

FILENAME=$1
USER=$(whoami)

[ -f "/home/${USER}/www/tools/files/config_manage/from_log.txt" ] && rm -rf "/home/${USER}/www/tools/files/config_manage/from_log.txt"

if [ "${FILENAME}" == "config.ini" ]; then
    echo "sudo cp -arf /home/${USER}/common-TEST/bin/${FILENAME} /home/${USER}/www/tools/files/config_manage/." >> /home/${USER}/www/tools/files/config_manage/from_log.txt
    sudo cp -arf /home/${USER}/common-TEST/bin/${FILENAME} /home/${USER}/www/tools/files/config_manage/.
elif [ "${FILENAME}" == "config00.ini" ]; then
    echo "sudo cp -arf /home/${USER}/servers1/${FILENAME} /home/${USER}/www/tools/files/config_manage/." >> /home/${USER}/www/tools/files/config_manage/from_log.txt
    sudo cp -arf /home/${USER}/servers1/${FILENAME} /home/${USER}/www/tools/files/config_manage/.
fi

sudo chmod 777 /home/${USER}/www/tools/files/config_manage/${FILENAME}
sudo chown ${USER}:${USER} /home/${USER}/www/tools/files/config_manage/${FILENAME}
