Unelte utilizator

Unelte site


mandriva:instalare:script_instalare

Script instalare aplicatii

Atentiune: varianta alpha.

Se copiaza fisierul scriptul de mai jos se salveaza cu denumirea start_mandriva.sh si se ruleaza ca root:

#bash start_mandriva.sh

FIXME FIXME

#!/bin/sh
# Quick and dirty script to download and install various 
# aplications
#
# Default values for important settings if not already in environment.
# These settings should not need editing here.

# Internal variables; these locations are not too important
RPM_CACHE=$HOME/rpmscache
# Default to hiding the directory, by popular demand
test -d "$RPM_CACHE" || RPM_CACHE=$HOME/.rpmscache

case "$1" in
-V|--version) 
  echo "Start Mandriva version 20080810.  (C) LGPL."
  exit 0
  ;;
esac

die() {
  echo "$@"

  case x"$GUI" in
  x1) xmessage -center "               Error: $@                 " ;;
  *) ;;
  esac

  exit 1
}


#----------------------------------------------------------------

usage() {
    set +x
    echo "Usage: $0 [options] package [package] ..."
    echo "This script can help you install applications"
    echo ""
    echo "Options:"
    echo " -q         quiet.  You must have already agreed to the EULAs."
    echo " -v         verbose"
    echo " -V         display Version"
    echo "Packages:"    
    echo " AdobeReader   PDF reader"
    echo " AdobeFlash    Flash player"
    echo " amule         File sharing client compatible with eDonkey"
    echo " firefox3      Next generation web browser"
    echo " krusader      Advanced KDE twin-panel file-manager"
    echo " ktorrent      BitTorrent program for KDE"
    echo " linuxdcpp     A DC++ port for Linux"
    echo " pidgin        A GTK+ based multiprotocol instant messaging client"
    echo " skype         Skype is free Internet telephony that just works"
    echo " webcore-fonts Collection of popular fonts distributed with MS Office 2007"
    echo " win32-codecs  Win32 codec binaries"
    echo " xchat         Graphical IRC client"
 }

#----------------------------------------------------------------
# Trivial GUI just to handle case where user tries running without commandline

# Checks for known desktop environments
# set variable DE to the desktop environments name, lowercase

detectDE() {
    if [ x"$KDE_FULL_SESSION" = x"true" ]
    then 
        DE=kde
    elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]
    then
        DE=gnome
    elif [ x"$DISPLAY" != x"" ]
    then
        DE=x
    else 
        DE=none
    fi
}

kde_showmenu() {
    title="$1"
    shift
    text="$1"
    shift
    col1name="$1"
    shift
    col2name="$1"
    shift
    while test $# -gt 0
    do
        args="$args $1 $1 off"
        shift
    done
    kdialog --title "$title" --separate-output --checklist "$text" $args
}

x_showmenu() {
    title="$1"
    shift
    text="$1"
    shift
    col1name="$1"
    shift
    col2name="$1"
    shift
    if test $# -gt 0
    then
        args="$1"
        shift
    fi
    while test $# -gt 0
    do
        args="$args,$1"
        shift
    done
    (echo "$title"; echo ""; echo "$text") > /tmp/x_showmenu.txt 
    xmessage -print -file /tmp/x_showmenu.txt -buttons "Cancel,$args" | sed 's/Cancel//'
}

showmenu()
{
    detectDE
    case $DE in
    kde) kde_showmenu "$@" ;;
    #gnome) gnome_showmenu "$@" ;;
    x) x_showmenu "$@" ;;
    none) usage 1>&2; exit 1;;
    esac
}
 
dogui()
{
  detectDE
  if [ $DE = gnome ]
  then
    echo "zenity --title 'Select a package to install' --text 'Install?' --list --checklist --column '' --column Package --column Description --height 440 --width 600 \\" > $RPM_CACHE/zenity.sh
    usage | grep '^ [a-z]' | sed 's/^ \([^ ]*\) *\(.*\)/FALSE "\1" '"'\2'/" | sed 's/$/ \\/' >> $RPM_CACHE/zenity.sh
    export todo="`sh $RPM_CACHE/zenity.sh | tr '|' ' '`"
  else
    packages=`usage | awk '/^ [a-z]/ {print $1}'`
    export todo="`showmenu "Start Mandriva" "Select a package to install" "Install?" "Package" $packages`"
  fi

  if test "$todo"x = x
  then
     exit 0
  fi
}

#----------------------------------------------------------------

GUI=0
case x"$1" in
x) GUI=1; dogui ; set $todo ;;
x-h|x--help|xhelp) usage ; exit 1 ;;
esac

#-----  Helpers  ------------------------------------------------

# Download a file
# Usage: package url [sha1sum [filename]]
# Caches downloads in winetrickscache/$package
download() {
    if [ "$4"x != ""x ]
    then
        file="$4"
    else
        file=`basename "$2"`
    fi
    cache="$RPM_CACHE/$1"
    mkdir -p "$cache"
    if ! test -f "$cache/$file"
    then
        cd "$cache"
        # Mac folks tend to have curl rather than wget
        # On Mac, 'which' doesn't return good exit status
        # Need to jam in --header "Accept-Encoding: gzip,deflate" else
        # redhat.com decompresses liberation-fonts.tar.gz!
        if [ -x "`which wget`" ]
        then
           # Use -nd to insulate ourselves from people who set -x in WGETRC
           # [*] --retry-connrefused works around the broken sf.net mirroring
           # system when downloading corefonts
           # [*] --read-timeout is useful on the adobe server that doesn't
           # close the connection unless you tell it to (control-C or closing
           # the socket)
           try wget -nd -c --read-timeout=300 --retry-connrefused --header "Accept-Encoding: gzip,deflate" "$2"
        else
           # curl doesn't get filename from the location given by the server!
           # fortunately, we know it
           try curl -L -o $file -C - --header "Accept-Encoding: gzip,deflate" "$2"
        fi
        cd "$olddir"
    fi
}


#----- One function per package, in alphabetical order ----------

load_AdobeReader() {
    download . http://ardownload.adobe.com/pub/adobe/reader/unix/8.x/8.1.2/enu/AdobeReader_enu-8.1.2_SU1-1.i486.rpm 
    urpmi --auto "$RPM_CACHE"/AdobeReader_enu-8.1.2_SU1-1.i486.rpm
}

#----------------------------------------------------------------

load_AdobeFlash() {
    download . http://fpdownload.macromedia.com/get/flashplayer/current/flash-plugin-9.0.124.0-release.i386.rpm
    urpmi --auto "$RPM_CACHE"/flash-plugin-9.0.124.0-release.i386.rpm
}

#----------------------------------------------------------------

load_amule() {
    urpmi --auto amule
}

#----------------------------------------------------------------

load_firefox3() {
    urpmi.addmedia backports http://ftp.iasi.roedu.net/mirrors/ftp.mandrake.com/official/2008.1/i586/media/main/backports/media_info/
    urpmi --auto firefox firefox-ro
}

#----------------------------------------------------------------


load_krusader() {
    urpmi --auto krusader
}

#----------------------------------------------------------------

load_ktorrent() {
    urpmi --auto ktorrent
}

#----------------------------------------------------------------

load_linuxdcpp() {
    urpmi --auto linuxdcpp
}

#----------------------------------------------------------------

load_pidgin() {
    urpmi --auto pidgin
}

#----------------------------------------------------------------

load_skype() {
    download . http://www.skype.com/go/getskype-linux-mdk 
    urpmi --auto --no-verify-rpm "$RPM_CACHE"/skype-*.rpm
}

#----------------------------------------------------------------

load_webcore-fonts() {
    download .  http://avi.alkalay.net/software/webcore-fonts/webcore-fonts-3.0-1.noarch.rpm
    urpmi --auto "$RPM_CACHE"/webcore-fonts-3.0-1.noarch.rpm
    download .  http://avi.alkalay.net/software/webcore-fonts/webcore-fonts-vista-3.0-1.noarch.rpm
    urpmi --auto "$RPM_CACHE"/webcore-fonts-vista-3.0-1.noarch.rpm
}

#----------------------------------------------------------------

load_win32-codecs() {
    urpmi --auto win32-codecs
}

#----------------------------------------------------------------

load_xchat() {
    urpmi --auto xchat
}

#----------------------------------------------------------------

while test "$1" != ""
do
    PACKAGE=$1
    case $1 in
    -v) set -x;;
    AdobeReader) load_AdobeReader;;
    AdobeFlash) load_AdobeFlash;;
    amule) load_amule;;
    firefox3) load-firefox3;;
    krusader) load_krusader;;
    ktorrent) load_ktorrent;;
    linuxdcpp) load_linuxdcpp;;
    pidgin) load_pidgin;;
    skype) load_skype;;
    webcore-fonts) load_webcore-fonts;;
    win32-codecs) load_win32-codecs;;
    xchat) load_xchat;;
    *) echo Unknown arg $1; usage ; exit 1;;
    esac
    # Provide a bit of feedback
    test "$WINETRICKS_QUIET" = "" && case $1 in 
    -q) echo Setting quiet mode;;
    -v) echo Setting verbose mode;;
    *) echo "Install of $1 done" ;;
    esac
    shift
done

# cleanup
rm -rf "$RPMS_CACHE"/*
mandriva/instalare/script_instalare.txt · Ultima modificare: 2008/08/10 09:10 (editare externă)