1 2 3 Previous Next 30 Replies Latest reply on Mar 21, 2007 9:17 AM by sbeaver Go to original post
      • 15. Re: Kickstart configs
        jasonboche Champion
        vExpert

        Steve, I ran part of your script and got an error

         

        \[root@vader /]# mkdir /tmp/post

        mv -f /etc/vmware/esx.conf /tmp/post/esx.conf.bak

        \[root@vader /]# mv -f /etc/vmware/esx.conf /tmp/post/esx.conf.bak

        \[root@vader /]# sed -e 's/boot\/memSize = \"272\"/boot\/memSize = \"512\"/g' /tmp/post/esx.conf.bak >> /etc/vmware/esx.conf

        \[root@vader /]# mv -f /boot/grub/grub.conf /tmp/post/grub.conf.bak

        \[root@vader /]# sed -e 's/uppermem 277504/uppermem 523264/g s/mem=272M/mem=512M/g' /tmp/post/grub.conf.bak >> /boot/grub/grub.conf

        sed: -e expression #1, char 37: Unknown option to `s'

        \[root@vader /]#

        /code

         

        Any idea what that last line is having a problem with?  The script appears to have nuked /boot/grub/grub.conf without putting anything back in its place.

        • 16. Re: Kickstart configs
          VirtualKenneth Master
          vExpert

          I had this before, when I again cut and paste the code from the internet (to VIM) in my script it worked again, very odd.

           

          Didn't checked for the cause though.

          • 17. Re: Kickstart configs
            VirtualKenneth Master
            vExpert

            This is how i cutted it out of my working script:

             

            sed -e 's/uppermem 277504/uppermem 523264/g' -e 's/mem=272M/mem=512M/g' /tmp/post/grub.conf.bak >> /boot/grub/grub.conf

            /code

             

            You are missing a " ' "behind the first search

            edit: You are missing much more behind that, i.e. the second "-e"

            • 18. Re: Kickstart configs
              sbeaver Guru
              User ModeratorsvExpert

              Try this...

              setSCmem()

              {

                echo "Setting Service Console memory to 512MB" #>> /root/PostInstall/PostInstall.log

                mv -f /etc/vmware/esx.conf /tmp/esx.conf.bak

                sed -e 's/boot\/memSize = \"272\"/boot\/memSize = \"512\"/g' /tmp/esx.conf.bak >> /etc/vmware/esx.conf

               

                mv -f /boot/grub/grub.conf /tmp/grub.conf.bak

                sed -e 's/uppermem 277504/uppermem 523264/g' -e 's/mem=272M/mem=512M/g' /tmp/grub.conf.bak >> /boot/grub/grub.conf

                echo "Service Console memory has been set to 512mb" #>> /root/PostInstall/PostInstall.log

              }

              /code

              • 19. Re: Kickstart configs
                jasonboche Champion
                vExpert

                I'll give it a try - thank you kindly gentlemen!  You seem to be experts with sed.

                 

                I was scouring the net last night trying to figure out how to use sed to find/replace a string of text that has some special characters in it which doesn't seem to be a simple task.  When sed sees special characters, it seems to behave differently.  The charcters I'm struggling with are  \ and #    Would either of you like to assist?

                 

                In a file, I need the only existing instance of this:

                PermitRootLogin no

                 

                changed to this:

                #PermitRootLogin no

                 

                 

                In a different file, I need the only existing instance of this:

                \u@\h \W

                 

                changed to this:

                \u@\h \w

                 

                \^^^^ notice the only change is the case of the W to w

                 

                The problem I was running into is that when sed comes across characters such as \ and #    The outcome doesn't work right.  For example, I think when it comes across the # sign, it interprets that as the beginning of a comment and ignores the rest of the line.

                 

                 

                • 20. Re: Kickstart configs
                  sbeaver Guru
                  vExpertUser Moderators

                  Not sure about the special characters BUT you can change the root logon a slightly different way and not use the #

                   

                  setSSHRoot()

                  {

                    echo "Allowing root to login via SSH..." >> /root/PostInstall/PostInstall.log

                    mv /etc/ssh/sshd_config /etc/ssh/sshd_config.old

                    sed -e "s/PermitRootLogin no/PermitRootLogin yes/g" /etc/ssh/sshd_config.old > /etc/ssh/sshd_config

                    rm -f /etc/ssh/sshd_config.old

                    /etc/init.d/ sshd restart

                    echo  "$scriptName - Set root to login via SSH" >> /root/PostInstall/PostInstall.log

                  }

                  /code

                  • 21. Re: Kickstart configs
                    jasonboche Champion
                    vExpert

                    Thanks Steve, the new version of the Service Console memory bump worked.  Would it be possible for you to incoporate the changes you made into your original script way up above so that it works properly?  That is a very nice collection of scripts, handy for others to use.

                     

                    I'll continue to work on the bashrc prompt update script.  Maybe I can figure it out eventually.  There are lots of resources on the net for sed

                     

                    Jas

                    • 22. Re: Kickstart configs
                      sbeaver Guru
                      User ModeratorsvExpert

                      I updated the post to reflect the change so it should work now

                      • 23. Re: Kickstart configs
                        jasonboche Champion
                        vExpert

                        In a different file, I need the only existing instance of this:

                        \u@\h \W

                         

                        changed to this:

                        \u@\h \w

                         

                        \^^^^ notice the only change is the case of the W to w

                         

                         

                        Got it!

                         

                        #Modification to display full path in COS bash prompt:

                        #Jason Boche

                        mv /etc/bashrc /etc/bashrc.old

                        sed -e "s/
                        h
                        \W/
                        h
                        \w/g" /etc/bashrc.old > /etc/bashrc

                        /code

                        • 24. Re: Kickstart configs
                          jasonboche Champion
                          vExpert

                          Thanks again Steve.

                          • 25. Re: Kickstart configs
                            sbeaver Guru
                            vExpertUser Moderators

                            Hey what are you doing here with this path in the COS?

                            • 26. Re: Kickstart configs
                              jasonboche Champion
                              vExpert

                              Let's say you're on the COS and you cd /etc/vmware/firewall

                               

                              The default prompt will show:

                              \[root@vader firewall]#

                               

                              After the scripted change, the prompt will show the full path of the directory you're in which I prefer (I'm an old DOS guy):

                              \[root@vader /etc/vmware/firewall]#

                              • 27. Re: Kickstart configs
                                sbeaver Guru
                                vExpertUser Moderators

                                Nice one!!  Good to know!! 

                                • 28. Re: Kickstart configs
                                  Jwoods Expert

                                  Nice addition!

                                  • 29. Re: Kickstart configs
                                    gogogo5 Expert

                                    hello

                                     

                                    bit of a n00b question on your script.  What does the # symbol do when you are piping to your PostInstall.log file  i.e. the #>> instead of just >>

                                     

                                    e.g.

                                     

                                    echo "Setting Service Console memory to 512MB" #>> /root/PostInstall/PostInstall.log