Advertisement
noes1s

BlackBuntu's Core

Jun 20th, 2011
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 7.66 KB | None | 0 0
  1. #!/bin/bash
  2. #  ,___    
  3. #  ¡  _`    BlackBuntu's Core
  4. #  ª_/()    noes1s
  5. #  |\` `,   http://pastebin.com/u/noes1s
  6. # _·'   l   CC BY-SA 3.0
  7. #___________________________________________________________________________________________________
  8. #Folders:
  9. bbuntu=/usr/share/Bbuntu
  10. icons=/usr/share/Bbuntu/icons
  11. logpath=/usr/share/Bbuntu/logs
  12. binpath=/usr/share/Bbuntu/bin
  13. folders=("$bbuntu" "$icons" "$logpath" "$binpath")
  14.  
  15. #___________________________________________________________________________________________________
  16. dependencies=(
  17.     aptitude
  18.     unzip
  19.     convert
  20. )
  21. remove=(
  22.     openoffice
  23. )
  24. repositories=(
  25.     ppa:tualatrix/ppa   #ubuntu-tweak
  26.     ppa:libreoffice/ppa
  27.     ppa:tiheum/equinox #faenza-icon-theme
  28. )
  29. install=(
  30.     ubuntu-tweak
  31.     libreoffice
  32.     libreoffice-gnome
  33.     faenza-icon-theme
  34.     computertemp
  35.     gimp
  36.     mplayer
  37.     smplayer
  38.     gnome-mplayer
  39.     sun-java6-jre
  40.     sun-java6-plugin
  41.     apache2
  42.     php5
  43.     libapache2-mod-php5
  44.     mysql-server
  45.     php5-mysql
  46.     phpmyadmin
  47. )
  48. ffaddons=(
  49.     noscript 722
  50.     foxyproxy 2464
  51. )
  52. #___________________________________________________________________________________________________
  53.  
  54. log(){ # $1(status) $2(name)
  55.     status=$1
  56.     [[ "$status" = '++' ]]&& status='\e[1;32m++\e[m'
  57.     [[ "$status" = '--' ]]&& status='\e[1;31m--\e[m'
  58.     [[ "$status" = '<<' ]]&& status='\e[1;33m<<\e[m'
  59.     [[ "$status" = '>>' ]]&& status='\e[1;35m>>\e[m'
  60.     [[ "$status" = '<>' ]]&& status='\e[1;37m>>\e[m'
  61.     [[ "$status" = '??' ]]&& status='\e[1;31m>>\e[m'
  62.     [[ "$status" = '**' ]]&& status='\e[1;32m>>\e[m'  
  63.     echo -e "[$(date +%R':'%S)] $status $2" >> $logpath/install.log
  64.     echo -e "[$(date +%R':'%S)] $status $2" > /dev/stdout
  65. }
  66.  
  67. addbin(){ # $1(name) $2(command) $3(term/--)
  68.     if [[ ! -e /usr/bin/$1.sh ]]; then
  69.         echo -e "#!/bin/sh\n" > /usr/bin/$1.sh
  70.         if [[ $3 = 'term' ]]; then
  71.             echo "gnome-terminal --title=$1 --working-directory=/tmp --command=$2" >> /usr/bin/$1.sh
  72.         else
  73.             echo "$2" >> /usr/bin/$1.sh
  74.         fi
  75.         chmod +x /usr/bin/$1.sh
  76.         log "+" "$1.sh chmod +x"
  77.         log "+" "$1.sh created in /usr/bin/."
  78.     else
  79.         log "I" "$1 already in /usr/bin. Not added." && return 1
  80.     fi
  81. }
  82.  
  83. adddirectory(){ # $1(name)
  84.     if [[ -e /usr/share/desktop-directories/$1.directory) ]]; then
  85.     echo "[Desktop Entry]
  86. Name=$1
  87. Comment=$1 tools
  88. Icon=/usr/share/Infond/pictures/$1.png
  89. Type=Directory
  90. Categories=$1" > /usr/share/desktop-directories/$1.directory
  91.         log "++" "$1.directory written"
  92.     else
  93.         log "<>" "$1.directory already exists. Not updated."
  94.     fi
  95. }
  96.  
  97. addicon(){ # $1(name) $2(link)
  98.     if [[ -e $icons/$1.png ]]; then
  99.         wget $2 -P /tmp
  100.         convert -size 48x48 /tmp/$2 -resize 48x48 -extent 48x48 +profile '*' $icons/$1.png
  101.         rm /tmp/$2
  102.         log "++" "$1 icon downloaded"    
  103.     else
  104.         log "<>" "$1 icon already exists. Not downloaded."
  105.     fi
  106. }
  107.  
  108. addcategory(){ # $1(name) $2(categories)
  109.     category=$(grep 'Categories' /usr/share/applications/$1.desktop |sed 's/.*=//')
  110.     if [[ -e /usr/share/applications/$1.desktop ]]; then
  111.         sed -i "s/Categories.*/Categories=$2;/" /usr/share/applications/$1.desktop &&
  112.         log "++" "$1.desktop $category changed to: $2"
  113.     else
  114.         log "??" "$1.desktop file not found"
  115.     fi
  116. }
  117.  
  118. addmenu(){ # $1(name) $2(comment) $3(command) $4(terminal=true/false) $5(category)
  119.     if [ -z "$(ls /usr/share/applications | grep $1.desktop)" ];then
  120.         echo "
  121. [Desktop Entry]
  122. Type=Application
  123. Encoding=UTF-8
  124. Name=$1
  125. Comment=$2
  126. Icon=/usr/share/Infond/pictures/$1.png
  127. Exec=$3
  128. Terminal=$4
  129. Categories=$5
  130.        " > /usr/share/applications/$1.desktop &&
  131.         log "++" "$1.desktop created"
  132.     else
  133.         log "<>" "$1.desktop already exists."
  134.     fi
  135. }
  136.  
  137. #___________________________________________________________________________________________________
  138. # START
  139. #___________________________________________________________________________________________________
  140.  
  141. #((UID)) && echo -e "\n\e[1;31m"' (!) '"\e[msudo bash $0\n" && exit 1
  142. ! ping -c2 tiny.cc >/dev/null && echo -e "\n\e[1;31m"' (!) '"\e[mInternet required\n" && exit 1
  143.  
  144. # Redirect outputs:
  145. 1>/dev/null
  146. 2>/dev/null
  147.  
  148. # Create required folders:
  149. for x in "${folders[@]}"; { [[ ! -e $x ]] && mkdir $x ;}
  150.  
  151. # Refresh/add log's date:
  152. [[ grep "$(date +%D)" $logpath/install.log ]]&& echo -e "\n$(date +%D)\n" >> $logpath/install.log
  153.  
  154. # Install required dependencies from "dependencies" list:
  155.     for x in "${dependencies[@]}"; do
  156.         if [[ ! which $x ]]; then
  157.             apt-get install -y $x && log "++" "$x installed" || log "??" "$x installation failed"
  158.             [[ $x = aptitude ]]&& aptitude update
  159.         fi
  160.     done
  161.  
  162. # Manual Repositories?
  163. # Dist-upgrade / Update / Upgrade?
  164. # Close firefox?
  165.  
  166. # Purge applications from "remove" list:
  167.     for x in "${remove[@]}"; do
  168.         state=$(aptitude show $x | awk '/State/{print $2}')
  169.         if [[ $state = installed ]]; then
  170.             apt-get --auto-remove -y --allow-unauthenticated purge $x &&
  171.             log '--' "$x removed and purged"
  172.         elif [[ $state = not ]]; then
  173.             log '<>' "$x not removed, not installed."
  174.         else
  175.             log '??' "$x removing error, not found."
  176.         fi
  177.     done
  178.  
  179. # Add all repositories from "repositories" list:
  180.     for x in "${repositories[@]}"; do
  181.         add-apt-repository $x
  182.         log '++' "The repository '$x' has been added."
  183.     done    
  184.  
  185. # Setup applications from "install" list:
  186.     for x in "${install[@]}"; do
  187.         state=$(aptitude show $x | awk '/State/{print $2}')
  188.         if [[ $state = not ]]; then
  189.             aptitude -y install $x &&
  190.             log '++' "$x has been installed."        
  191.         elif [[ $state = installed ]]; then
  192.             aptitude -y install $x &&
  193.             log '<>' "$x using the latest version."
  194.         else
  195.             log '??' "$x installation error, not found."
  196.         fi
  197.     done
  198.  
  199. # Change application's category:
  200.  
  201. # Install firefox extensions from "ffaddon" list:
  202.     extensionDir="/usr/share/mozilla/extensions/$(ls /usr/share/mozilla/extensions)"
  203.     addlink=https://addons.mozilla.org/en-US/firefox/downloads/latest
  204.     for x in "${ffaddons[@]}"; do
  205.         app=$(echo $x |awk {print $1})
  206.         number=$(echo $x |awk {print $2})
  207.         if [[ -z "$(ls -R $extensionDir | grep $app)" ]]; then
  208.             wget $addlink/$number/addon-$number-latest.xpi -nc -P $extensionDir &&
  209.             log "++" "$app firefox extension installed."
  210.         else
  211.             log "<>" "$app firefox extension already installed. .xpi not downloaded."
  212.         fi
  213.     done
  214.     firefox -silent -offline
  215.  
  216. #___________________________________________________________________________________________________
  217. #
  218. # Custom installations / configurations
  219. # _________________________________
  220. # apache2, php, mysql, phpmyadmin
  221.  
  222.     log '**' 'Configuring Apache2...'
  223.     # configure for local use only
  224.     echo Listen 127.0.0.1:80 > /etc/apache2/ports.conf
  225.     echo Listen 127.0.0.1:443 >> /etc/apache2/ports.conf
  226.  
  227.     # ssl
  228.     a2enmod ssl
  229.     make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/ssl/private/localhost.pem
  230.     cp /etc/apache2/sites-available/default /etc/apache2/sites-available/ssl
  231.     sed -i '1,2s/\*:80/*:443/' /etc/apache2/sites-available/ssl
  232.     sed -i "3a\\\tSSLEngine On\n\tSSLCertificateFile /etc/ssl/private/localhost.pem" \
  233.     /etc/apache2/sites-available/ssl
  234.     a2ensite ssl
  235.  
  236.     # restart apache
  237.     /etc/init.d/apache2 restart
  238.  
  239.  
  240. # chmod every other files
  241. id=$(ls /home)
  242. chown $id:$id /usr/share/Bbuntu -R
  243. chmod -R 744 /usr/share/Bbuntu
  244.  
  245. # EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement