Компьютерный форум OSzone.net  

Компьютерный форум OSzone.net (http://forum.oszone.net/index.php)
-   Вебмастеру (http://forum.oszone.net/forumdisplay.php?f=22)
-   -   Чем открыть для просмотра файл .sh (бэкап lampp) (http://forum.oszone.net/showthread.php?t=301648)

Yewgeniy 25-06-2015 11:54 2522304

Чем открыть для просмотра файл .sh (бэкап lampp)
 
Имеется файл с расширением .sh. Содержимое както нечитабельно кодировано. Какой есть просмотрщик?

mar 25-06-2015 11:58 2522306

что значит "нечитабельно кодировано"? кодировка файла и локали не совпадает? так это только на комментариях отразится - остальной-то код должен читаться т.к. он идет латиницей

Yewgeniy 25-06-2015 13:28 2522329

в ноутпаде выглядит вот так

Iska 25-06-2015 14:34 2522361

Yewgeniy, покажите весь читабельный кусок сценария.

Yewgeniy 25-06-2015 15:00 2522362

весь читабельный кусок
#!/bin/bash
# Copyright 2003-2004 by Kai 'Oswald' Seidler, oswald@apachefriends.org, GPL-licensed

skip=151

# check the md5sum of a singe file
function checksum
{
origsum=`egrep " $1$" md5sums`
mysum=`md5sum $1`

if test -z "$origsum"
then
return
fi

if test "$origsum" = "$mysum"
then
:
else
echo "$i: FAILED."
echo "Sorry, your backup file is corrupt."
echo "Please email to oswald@apachefriends.org for help."
exit
fi
}

backupdir="/opt/lampp/backup"

if test "`whoami`" != "root"
then
echo "Please run me as root."
exit
fi

case $0 in
/*) this=$0;;
*) this=`pwd`/$0;;
esac

if test -e "$this"
then
:
else
echo "Something went wrong."
echo "Can you call me in a different way?"
exit
fi


if test -d $backupdir
then
:
else
(
mkdir $backupdir
chown root.root $backupdir
chmod 700 $backupdir
 ) 2> /dev/null
fi

restoredir="/opt/lampp/backup/$$"

mkdir $restoredir 2> /dev/null

cd $restoredir 2> /dev/null || (echo "Please install a vanilla XAMPP first"; exit)

. /opt/lampp/share/lampp/lampplib

if test "$1" != ""
then
passwd="-p$1"
else
passwd=""
fi

if /opt/lampp/bin/mysqladmin -uroot reload $passwd 2>/dev/null
then
:
else
echo "Can't access your MySQL database."
echo "a) Did you start it?"
echo "b) Add the MySQL root password to end of command line"
exit
fi

tail -n +$skip "$this" | gzip -dc - 2>/dev/null | tar xf -

echo "Checking integrity of files..."

for i in *
do
checksum $i
done

echo "Restoring configuration, log and htdocs files..."

tar xfz data.tar.gz -C /

echo "Checking versions..."

iam=`cat VERSION`
installed=`cat /opt/lampp/lib/VERSION`

echo "Installed: XAMPP $installed"
echo "Backup from: XAMPP $iam"

if test "$installed" != "$iam"
then
echo "The backup sofware is not able to handle different XAMPP versions."
echo "Your backuped configuration from $iam may not work with $installed and may need manually corrections."
if askn "Do you want to continue"
then
echo "Let's try..."
else
echo "Good choice."
exit
fi
fi

echo "Restoring MySQL databases..."

for i in *.sql
do
if test "$i" = "mysql.sql"
then
continue
fi
/opt/lampp/bin/mysql -uroot $passwd < $i 2> output
if test $? != 0
then
echo -n "`basename $i .sql` FAILED: "
cat output
fi
done

echo "Restoring MySQL user databases..."
/opt/lampp/bin/mysql -uroot $passwd < mysql.sql 2> output
if test $? != 0
then
echo -n "MySQL user FAILED: "
cat output
fi

echo "Backup complete. Have fun!"
echo "You may need to restart XAMPP to complete the restore."

rm -rf $restoredir
exit
##BACKUPDATA##

Iska 25-06-2015 15:32 2522385

Yewgeniy, замечательно! Теперь Вам надо либо дождаться специалиста по bash, либо самому сходить с этим в соответствующий раздел конференции, дабы он мог по приведённому коду подсказать, как и чем именно обрабатывается оставшаяся часть пакетного файла bash от «##BACKUPDATA##» и ниже.

DedAlex 26-06-2015 08:40 2522638

Я не специалист, но похоже это .tar.gz архив.


Время: 13:18.

Время: 13:18.
© OSzone.net 2001-