torsdag 5 mars 2015

Linux - bash add ppa, yes or no to run command, show size of folder, mfl

#!/bin/bash

version="1.2.3"
install="sudo apt-get install "
versionof=echo This is $version of installos-install.sh

# Start of adding PPA
if ! grep -q "$the_ppa01" /etc/apt/sources.list /etc/apt/sources.list.d/-; then
 # commands to add the ppa ...
echo "ppa not found, adding:"
 sudo sh -c "echo $the_ppa01 >> /etc/apt/sources.list"
fi
if ! grep -q "$the_ppa02" /etc/apt/sources.list /etc/apt/sources.list.d/-; then
 # commands to add the ppa ...
echo "ppa not found, adding:"
 sudo sh -c "echo $the_ppa02 >> /etc/apt/sources.list"
fi
sudo apt-get update
# end of exempel add ppa
#-------------------------------------------------------------------------------------------
# End od adding PPA

# skapar mapp om den saknas
# Kopierar nerladdade filer: #-(03)
if [ ! -d /root/deb/ ]; then
  mkdir /root/deb/
fi
 sudo mv /var/cache/apt/archives/*.deb /root/deb/

$versionof
----------------------------------------------------------------------
# Base install start
echo "Would you like to run base install [y/n]?"
read ans
if [ $ans = y -o $ans = Y -o $ans = yes -o $ans = Yes -o $ans = YES ]
then
echo "'yes'"

#Följande ytterligare paket kommer att installeras:
sudo apt-get install apt-rdepends emacs24 xterm super vim dselect lynx

fi
if [ $ans = n -o $ans = N -o $ans = no -o $ans = No -o $ans = NO ]
then
echo "'no'"
fi
#----------------------------------------------------------------------
# End of Base Install


#----------------------------------------------------------------------
echo "Would you like to run apt-get upgrade [y/n]?"
read ans
if [ $ans = y -o $ans = Y -o $ans = yes -o $ans = Yes -o $ans = YES ]
then
echo "'yes'"
sudo apt-get upgrade
fi
if [ $ans = n -o $ans = N -o $ans = no -o $ans = No -o $ans = NO ]
then
echo "'no'"
fi
#----------------------------------------------------------------------
echo "Would you like to run apt-get -f install [y/n]?"
read ans
if [ $ans = y -o $ans = Y -o $ans = yes -o $ans = Yes -o $ans = YES ]
then
echo "'yes'"
sudo apt-get -f install
fi
if [ $ans = n -o $ans = N -o $ans = no -o $ans = No -o $ans = NO ]
then
echo "'no'"
fi
#----------------------------------------------------------------------
echo "Would you like to run dpkg --configure -a [y/n]?"
read ans
if [ $ans = y -o $ans = Y -o $ans = yes -o $ans = Yes -o $ans = YES ]
then
echo "'yes'"
sudo dpkg --configure -a
fi
if [ $ans = n -o $ans = N -o $ans = no -o $ans = No -o $ans = NO ]
then
echo "'no'"
fi
#----------------------------------------------------------------------

# Kopierar nerladdade filer: #-(03)-01
# skapar mapp om den saknas
if [ ! -d /root/deb/ ]; then
  mkdir /root/deb/
fi && sudo mv /var/cache/apt/archives/*.deb /root/deb/
 
# Show size of folder used to store *.deb
clear && echo After copy to root && du -csh /root/deb /var/cache/apt/archives && echo hanterar deb filer && echo installos v $version && echo hynt@speed-mailer.com
Skicka en kommentar