Nieuws:

Welkom, Gast. Alsjeblieft inloggen of registreren.
Heb je de activerings-mail niet ontvangen?

Auteur Topic: Zelf uitpakkende .tar.gz op vaste locatie  (gelezen 2533 keer)

Zelf uitpakkende .tar.gz op vaste locatie
« Gepost op: 2011/11/04, 15:36:59 »
Ik wil graag een zelfuitpakkende .tar.gz maken, maar dan wel dat het op een vaste locatie word uitgepakt.
Het script wat ik gebruik voor het 'zelf uitpakken' is:
#!/bin/bash
echo "Extracting file into `pwd`"
SKIP=`awk '/^__TARFILE_FOLLOWS__/ { print NR + 1; exit 0; }' $0`
THIS=`pwd`/$0
tail -n +$SKIP $THIS | tar -xz
echo "Finished"
exit 0
__TARFILE_FOLLOWS__
Waar kan ik dan in dit script aangeven dat het op een vaste locatie word uitgepakt? Of is dat wel mogelijk?
Workstation:
Dell Precision 690 Workstation
Dual Xeon X5365 Quad (8-Cores @3.0GHz)
64GB DDR2 R.A.M.
Sapphire Radeon HD 6570 (2GB GDDR3)

PC:
Dell OptiPlex 755
Intel Core 2 Duo E8400 (2-Cores @3,00Ghz)
4GB DDR2 R.A.M.
ATi Radeon HD 2400 XT (258MB GDDR2)

IGN: brickmasterj (of brickmaster-j)

Re: Zelf uitpakkende .tar.gz op vaste locatie
« Reactie #1 Gepost op: 2011/11/04, 18:00:04 »
Brickmasterj,

Yep, een beetje aanpassen:
#!/bin/bash
# Self Extracting Template File Extract.sh
# Destination directory is DIR
# Usage: cat Extract.sh tarfile > SelfExtract.sh

DIR=/var/tmp

echo "Extracting file into $DIR"
# searches for the line number where finish the script and start the tar.gz
SKIP=`awk '/^__TARFILE_FOLLOWS__/ { print NR + 1; exit 0; }' $0`
#remember our file name
THIS=`pwd`/$0
# take the tarfile and pipe it into tar
tail -n +$SKIP $THIS | tar -xz --directory=$DIR
# Any script here will happen after the tar file extract.
echo "Finished"
exit 0
# NOTE: Don't place any newline characters after the last line below.
__TARFILE_FOLLOWS__

Op deze manier wordt de tar-ball uitgepakt in /var/tmp/.....
Je hoeft alleen wat achter DIR= staat te wijzigen.
MvG,
MauRice
Registered Linux user: 473556

Re: Zelf uitpakkende .tar.gz op vaste locatie
« Reactie #2 Gepost op: 2011/11/04, 18:38:03 »
Brickmasterj,

Yep, een beetje aanpassen:
#!/bin/bash
# Self Extracting Template File Extract.sh
# Destination directory is DIR
# Usage: cat Extract.sh tarfile > SelfExtract.sh

DIR=/var/tmp

echo "Extracting file into $DIR"
# searches for the line number where finish the script and start the tar.gz
SKIP=`awk '/^__TARFILE_FOLLOWS__/ { print NR + 1; exit 0; }' $0`
#remember our file name
THIS=`pwd`/$0
# take the tarfile and pipe it into tar
tail -n +$SKIP $THIS | tar -xz --directory=$DIR
# Any script here will happen after the tar file extract.
echo "Finished"
exit 0
# NOTE: Don't place any newline characters after the last line below.
__TARFILE_FOLLOWS__

Op deze manier wordt de tar-ball uitgepakt in /var/tmp/.....
Je hoeft alleen wat achter DIR= staat te wijzigen.
Haha, Dankje wel!
Workstation:
Dell Precision 690 Workstation
Dual Xeon X5365 Quad (8-Cores @3.0GHz)
64GB DDR2 R.A.M.
Sapphire Radeon HD 6570 (2GB GDDR3)

PC:
Dell OptiPlex 755
Intel Core 2 Duo E8400 (2-Cores @3,00Ghz)
4GB DDR2 R.A.M.
ATi Radeon HD 2400 XT (258MB GDDR2)

IGN: brickmasterj (of brickmaster-j)

Re: Zelf uitpakkende .tar.gz op vaste locatie
« Reactie #3 Gepost op: 2011/11/04, 18:56:45 »
Brickmasterj,

Geen dank, graag gedaan.
MvG,
MauRice
Registered Linux user: 473556