????JFIF??x?x????'
| Server IP : 79.136.114.73 / Your IP : 216.73.216.107 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/self/root/opt/restore/ |
Upload File : |
#!/bin/bash
# /opt/restore/create_permissions_script.sh
ARCHIVE_DIR=`pwd`
PACKAGES=`ls $ARCHIVE_DIR/*.deb`
cd $ARCHIVE_DIR
cd /
function changePerms()
{
CHOWN="/bin/chown"
CHMOD="/bin/chmod"
PERMS=`echo $1 | sed -e 's/--x/1/g' -e 's/-w-/2/g' -e 's/-wx/3/g' -e 's/r--/4/g' -e 's/r-x/5/g' -e 's/rw-/6/g' -e 's/rwx/7/g' -e 's/---/0/g'`
FTYPE=`echo ${PERMS:0:1}`
PERMS=`echo ${PERMS:1}`
OWN=`echo $2 | /usr/bin/tr '/' '.'`
PATHNAME=$3
PATHNAME=`echo ${PATHNAME:1}`
if [[ "d" = "$FTYPE" ]]; then
echo "$CHOWN -R $OWN $PATHNAME" >> "${ARCHIVE_DIR}/dir_perms.sh"
echo "$CHMOD $PERMS $PATHNAME" >> "${ARCHIVE_DIR}/dir_perms.sh"
else
echo "$CHOWN $OWN $PATHNAME" >> "${ARCHIVE_DIR}/file_perms.sh"
echo "$CHMOD $PERMS $PATHNAME" >> "${ARCHIVE_DIR}/file_perms.sh"
fi;
#fi;
}
for PACKAGE in $PACKAGES;
do
if [ -d $PACKAGE ]; then
continue;
fi
echo "Getting information for $PACKAGE"
FILES=`/usr/bin/dpkg -c "${PACKAGE}"`
for FILE in "$FILES";
do
echo "$FILE" | awk '{print $1"\t"$2"\t"$6}' | while read line;
do
changePerms $line
done
done
done
sort "${ARCHIVE_DIR}/dir_perms.sh" | uniq > "${ARCHIVE_DIR}/clean_dir_perms.sh"
sort "${ARCHIVE_DIR}/file_perms.sh" | uniq > "${ARCHIVE_DIR}/clean_file_perms.sh"
cat "${ARCHIVE_DIR}/clean_dir_perms.sh" "${ARCHIVE_DIR}/clean_file_perms.sh" > "${ARCHIVE_DIR}/restore_permissions.sh"
rm "${ARCHIVE_DIR}/clean_dir_perms.sh" "${ARCHIVE_DIR}/clean_file_perms.sh" "${ARCHIVE_DIR}/dir_perms.sh" "${ARCHIVE_DIR}/file_perms.sh"