We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7455
    • 2,204 Posts
    Quote from: davidm at Nov 29, 2006, 12:43 PM

    @Dimmy : Is that what you’re looking for smiley ?

    jup thats it

    with tar we could also give the right permissions to folders and it will keep those permissions when extracting that way there is no need to chmod the files and folders of the instalation.
      follow me on twitter: @dimmy01
    • Very interesting stuff... has anyone played with that tar lib, and know if it works on Windows + Linux w/o dependencies?
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 10746
        • 126 Posts
        Quote from: kylej at Nov 29, 2006, 01:15 PM

        I had no problems with permissions, or having to reset permissions on any files. Dimmy, could you explain the issue there a little more?

        Although I am not Dimmy, I will throw in my 2c worth, because I have had problems with permissions...

        On Linux each newly created file is given a set of permissions that depends on a user-variable (umask) .. if this variable is set to an inconvenient value, then all the new files will have inappropriate permissions for MODx - for example, each directory MUST have "r-x" access (or rwx access) for the web server or the web server will not be able to read (the "r") or navigate through (the "x") the directory. Similarly each file should have at least "r--" permissions for the web server.

        Using a gzipped tar archive with the appropriate flag (-p) while extracting

        tar xzvpf <file>.tar.gz

        will extract all the files and KEEP THE ORIGINAL PERMISSIONS rather than giving all the extracted files default permissions. So provided the tar file was created from a working installation, it will still work unchanged.

        Otherwise, as I have painfully discovered, you need to go through and manually fix up all the permissions (or cheat and just do "chmod -R 755 *").

        I don’t know what happens with zip ... and I imagine that a zip archive created on Win might act differently than one created on Mac OS or Linux... when I unzipped "Maxigallery" it used my default (crappy) umask, but other things work OK.

        If by chance or design your umask is OK, then you will never even notice this issue...


        Cheers

        Gordon




          • 6726
          • 7,075 Posts
          that’s right gfroyle you can indeed use this method but for this you need shell access which not everyone has, plus you need to know the command line to make it work (if like me you don’t, it’s a painful process).

          I had tried tar -zcvf <file>.tar.gz which worked but replicated the directory structure of the archive. I re-created the archive with no to directory but then the system created one anyway /user/... )

          If you know the command line, what should I do about that ?
            .: COO - Commerce Guys - Community Driven Innovation :.


            MODx est l&#39;outil id
            • 10746
            • 126 Posts
            Quote from: davidm at Dec 07, 2006, 09:43 AM

            I had tried tar -zcvf <file>.tar.gz which worked but replicated the directory structure of the archive. I re-created the archive with no to directory but then the system created one anyway /user/... )

            If you know the command line, what should I do about that ?

            Sorry, I must not be understanding what you *want* to do...

            A tar archive contains a complete directory structure, and extracting the files will create that directory structure (as a sub-directory of your current one) ... but this is usually exactly what you WANT... (at least what I want).

            So if the archive contains

            Directory A
            -- File A1
            -- File A2
            -- File X
            Directory B
            -- File B1
            -- File B2
            -- File X

            then when it is unpacked you have files A/A1, A/A2, A/X, B/B1, B/B2, B/X which is what you would expect (no?)


            So I am not clear what else you would want it to do.. maybe you could explain and then we can work out how to do it..

            Best

            Gordon
              • 6726
              • 7,075 Posts
              To moderator : I think this could be a separate thread about untarring MODx archives from the server, we’re highjacking Kyle’s thread here wink

              Let me explain.

              The MODx tar.gz archive contains a directory structure alright : all files are extracted in a /modx-0.9.5/ folder
              When you upload your archive, it gets uncompressed not at the root of your install folder but naturally in a /modx-0.9.5/ folder

              What I did was select all files in the /modx-0.9.5/ folder and created a tar.gz file of my own from there. You’d think when you untar, it would just untar in the root directory as expected. But on my server it’s untarred into a /user/ folder ( huh probably server related, I untarred it as root, with SSH) so I figured is there a parameter to tell it to untar where you want it. Or else it’s my bad and I tarred it wrong (used FasTar on Mac OS X, not being command line savvy).

              Maybe it’s got something to do with ownership of the files or something (my dedicated box is running Linux)...
              I’ll probably ask my administrator to explain and teach me this... but if you have input, by all means smiley


                .: COO - Commerce Guys - Community Driven Innovation :.


                MODx est l&#39;outil id
                • 10746
                • 126 Posts
                Why not move the files after extracting them from the tarball?

                Suppose you untar the archive, so you now have

                modx-0.9.5/assets
                modx-0.9.5/manager
                ...
                etc

                But you WANT them to be somewhere else - in my case, the location I need to put them is the area where the webserver expects them to be, which happens to be ~gordon/WWW (yours will be different).

                So then I "change directory" (cd) to the modx-0.9.5 location and "copy" (cp) the files...

                cd modx-0.9.5    (you may need a full path name)
                cp -r * ~gordon/WWW

                This then copies "modx-0.9.5/assets" and all its subdirectories and files to the location ~gordon/WWW/assets, and so on for all the other things...

                This will

                - copy new files to the correct place in the existing directory structure (or create the directory structure if there isn’t one).
                - overwrite existing files with the same names
                - leave old files untouched


                For complete safety, I follow the "alternate upgrade" path on the Wiki and FIRST make copies of everything..

                cp -r assets assets-old
                cp -r manager manager-old
                ...
                cp -r index.php index.php-old

                so that if I accidentally overwrite something that I actually needed (because, maybe I had customized it) then I have a new version.

                OR, if you want the new install to be completely fresh, then

                mv assets assets-old
                mv manager manager-old
                ...
                mv ...

                and then install everything and then just grab your own customized files/images etc from "assets-old"

                HTH

                Gordon

                PS In answer to your question, normally the files are extracted as subdirectories of whatever directory you are "in" when you issue the "tar x" command...  I don’t know if that might be different on other systems.