Jump to content

kde install script


Guest c_m_f
 Share

Recommended Posts

Right then started out writing a basic install script for open ssl, qt, arts, kdelibs and kdebase

 

now i have come to some dead ends as its past my knowledge of basic commands, there are three things i would like to add to the script:

 

1. edit the two files ~/.profile and ~/.bash _profile and adding the lines for qt and kde automatically, so how could i determine the line '/usr/local/kde/bin' needs to be added to ~/.bash_profile and then adding it to that line.

and creating the file ~/.profile with the content

[QTDIR=/usr/local/qt

       PATH=$QTDIR/bin:$PATH

MANPATH=$QTDIR/doc/man:$MANPATH

LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH



export QTDIR PATH MANPATH LD_LIBRARY_PATH

 

2. how to print a message and add the ability to say yes or no which will do the following, assuming after configuring the arts the script asks if the configure went ok, and asking wether any dependencies need to be installed, so if it went ok you would type 'yes and if any deps need to be installed you would type 'no' and a second message would ask if you want the script to wait for you to add any dependencies or exit.

 

at the first question a 60 second timer would be initalized and if no response is given it assumes the default of 'yes

 

so if anybody knows of ways to do this, a suggestion would be great or any alternatives to my suggestions, here is my code up to now:

 

cd /kde

cp qt-x11-free-3.1.1.tar /usr/local

cp openssl-0.9.7.tar.gz /usr/local

cd /usr/local

tar -xf qt-x11-free-3.1.1.tar

gunzip openssl-0.9.7.tar.gz

tar -xf openssl-0.9.7.tar

mv qt-x11-free-3.1.1 qt

cd openssl-0.9.7

./config

make

make test

make install





cd /usr/local/qt

./configure -thread -qt-gif

gmake





cd /kde

mkdir done

tar jxvf arts-1.1.tar.bz2

mv arts-1.1.tar.bz2 done

cd arts-1.1

./configure --with-alsa

make

make install





cd /kde

rm -d -f arts-1.1

tar jxvf kdelibs-3.1.tar.bz2

mv kdelibs-3.1.tar.bz2 done

cd kdelibs-3.1

./configure --with-ssl-dir=/usr/local/ssl --with-alsa

make

make install





cd /kde

rm -d -f kdelibs-3.1

tar jxvf kdebase-3.1.tar.bz2

mv kdebase-3.1.tar.bz2 done

cd kdebase-3.1

./configure --with-x --with-ssl-dir=/usr/local/ssl

make

make install





cd /kde

rm -d -f kdebase-3.1

tar jxvf kdemultimedia-3.1.tar.bz2

mv kdemultimedia-3.1.tar.bz2 done

cd kdemultimedia-3.1

./configure --with-x --with-arts-alsa

make

make install



cd /kde

rm -d -f kdemultimedia-3.1

Link to comment
Share on other sites

  • 2 weeks later...
1. edit the two files ~/.profile and ~/.bash _profile and adding the lines for qt and kde automatically, so how could i determine the line '/usr/local/kde/bin' needs to be added to ~/.bash_profile and then adding it to that line.

Ive just noticed this thread, and I'm not sure what are you really wanting to do.

and creating the file ~/.profile with the content

Nope, both ~/.profile and ~/.bash_profile are incompatible. On a login shell bash will look for the files ~/.bash_profile, ~/.bash_login, and ~/.profile in that order, and will read and execute the commands only from the first one that exists and can be read.

[QTDIR=/usr/local/qt

       PATH=$QTDIR/bin:$PATH

MANPATH=$QTDIR/doc/man:$MANPATH

LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH



export QTDIR PATH MANPATH LD_LIBRARY_PATH

So asuming that you wanted to add those statements to all of your normal user's, here is a little script that will update all your "normal user's" .bash_profile with those parameters you want.

bprofile=".bash_profile"

qtdir='QTDIR=/usr/local/qt'

path='PATH=$QTDIR/bin:$PATH'

mpath='MANPATH=$QTDIR/doc/man:$MANPATH'

lpath='LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH'

xport='export QTDIR PATH MANPATH LD_LIBRARY_PATH'



awk 'FS=":" {

       if ($3 > 500) {print $6}

       }' /etc/passwd | while read user_home

       do

               profile=${user_home}/${bprofile}

               if ! grep -q "$qtdir"; then

                       echo "$QTDIR" >> "$profile"

               fi

               if ! grep -q "$path"; then

                       echo "$path" >> "$profile"

               fi

               if ! grep -q "$mpath"; then

                       echo "$mpath" >> "$profile"

               fi

               if ! grep -q "$lpath"; then

                       echo "$lpath" >> "$profile"

               fi

               if ! grep -q "$xport"; then

                       echo "$xport" >> "$profile"

               fi

       done

 

NOT TESTED, but I'm sure that that would do the trick in a "rough manner".

If you want to be more elegant you can edit the variable assignments, for example to update the $PATH variable:

 

if ! egrep -q "<PATH=.*QTDIR.*" $profile; then

       if egrep -q "<PATH=" $profile; then

               sed "/<PATH=.*/ {s@(<PATH=)(.*)@1$QTDIR/bin:2@;}" $profile > tmp

               cat tmp > $profile && rm tmp

       else

               echo "$path" >> "$profile"

       fi

fi

Again NOT TESTED! But that will avoid having duplicated paths.

 

In addition, if you want the new users to have those parameters by default you'll need to update the /etc/skell/.bash_profile file.

 

HTH

Link to comment
Share on other sites

2. how to print a message and add the ability to say yes or no which will do the following, assuming after configuring the arts the script asks if the configure went ok, and asking wether any dependencies need to be installed, so if it went ok you would type 'yes and if any deps need to be installed you would type 'no' and a second message would ask if you want the script to wait for you to add any dependencies or exit.

 

at the first question a 60 second timer would be initalized and if no response is given it assumes the default of 'yes

To answer your question in a generic way:

 

previous_stuff_ends

while :; do

   #--> if time is out $answ will be yes, otherwise get user's input

   echo -n "Continue? (y/n): "; read -t 60 answ || answ=yes 

   case "$answ" in

        [yY]|[yY][eE][sS])  do_positive_stuff && exit;;

        [nN]|[nN][oO]) do_negative_stuff && exit;;

        *) :;;

   esac

done

 

the way I would do it (w/o user's interaction):

if ! previous_stuff_ends; then  #--> The previous stuff returns an error status.

     echo "dependences are needed" >&2 && exit 1

fi

do_positive_stuff

 

HTH

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...