quarta-feira, 16 de outubro de 2013

Cor de fundo do Grub2 no Ubuntu

Não gosta da cor de fundo "roxa" do grub no Ubuntu?

Se quiser mudar para um fundo preto, abra um terminal Ctrl+Alt+T

E execute o seguinte comando:

sudo sed -i.bak 's/44,0,30;/0,0,0;/g' /lib/plymouth/themes/default.grub && sudo update-grub

terça-feira, 27 de agosto de 2013

Update and boot Ubuntu daily-live ISO from GRUB2

Ubuntu 13.10 is almost here. Want to try it?

Script to update (sync) Ubuntu-daily-live.iso and boot ISO file from GRUB2
Need sudo permissions only when run for the first time (install dependencies and add custom menu entry on grub).

Here is the script to update Ubuntu daily-live ISO and boot from GRUB2.

#!/bin/bash
#Script to update and boot Ubuntu daily-live ISO with GRUB2
#Autor João Sousa tuxmind.blogspot.com
#Version 0.1

### Find /home partition "number"
N_PARTICAO=`df /home | tail -1 | cut -c9`

### Install curl and zsync (Add repo "universe")
which curl || sudo apt-get install -y curl
#"sudo software-properties-gtk -e universe" deprecated?
which zsync || (sudo apt-get update; sudo add-apt-repository universe; sudo apt-get update; sudo apt-get install -y zsync)

### Find last "daily-live" codename (future URL changes will break this :( send me your feedback if you know a better way to do this :P )
codename=`curl -s http://cdimage.ubuntu.com/daily-live/current/MD5SUMS | head -1 | cut -d* -f2 | cut -d- -f1`

cd

### zsync download/update ISO file
zsync http://cdimage.ubuntu.com/daily-live/current/$codename-desktop-i386.iso.zsync && echo "Image $codename-desktop-i386.iso is update"

### Remove simbolic link (only if exist)
rm -f Ubuntu-desktop-i386.iso

### Simbolic link to Ubuntu-desktop-i386.iso
ln -s $codename-desktop-i386.iso Ubuntu-desktop-i386.iso

### Separate home partition?
RAIZ=`echo "/$USER"`
### Or... same partition?
[ `df / | tail -1 | cut -d" " -f1` == `df /home | tail -1 | cut -d" " -f1` ] && RAIZ=`echo "/home/$USER"`

### Created "42_ubuntu-daily-live" (if doesn't exist)
if [ -e /etc/grub.d/42_ubuntu-daily-live ];
then

echo "42_ubuntu-daily-live ok"

else

### Add new boot option to Grub2
cat > 42_ubuntu-daily-live << EOF
#!/bin/sh
exec tail -n +3 \$0

menuentry "Ubuntu $codename daily-live" {
set isofile="$RAIZ/Ubuntu-desktop-i386.iso"
loopback loop (hd0,$N_PARTICAO)\$isofile
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=\$isofile noprompt quiet splash --
initrd (loop)/casper/initrd.lz
}
EOF

### Move file "42_ubuntu-daily-live" to /etc/grub.d
sudo mv 42_ubuntu-daily-live /etc/grub.d/42_ubuntu-daily-live

### Change permissions
sudo chmod +x /etc/grub.d/42_ubuntu-daily-live

### Update Grub menu list
sudo update-grub

fi

Reverting changes made by Ubuntu_daily-live_Grub.sh script:

cd /etc/grub.d/
sudo rm -f 42_ubuntu-daily-live
sudo update-grub

domingo, 9 de junho de 2013

Android SDK Ubuntu 13.04

Um pequeno shell script que eu criei para instalar o Android ADT Bundle no Ubuntu 13.04.

O que o script faz?

  • O script baixa o Android ADT Bundle, indicado para o seu sistema x86 ou x86_64 (Adb tools, SDK e eclipse está tudo incluído)
  • Instala o openjdk (a Google recomenda instalar o java da Oracle, mas até hoje não tive problemas com o openjdk)
  • Cria um shortcut na Área de trabalho .
  • Cria uma path no bashrc para podermos usar o adb na consola sem precisar indicar o caminho completo.

#!/bin/bash
#Script to Install and Setting Up the Android ADT Bundle for Ubuntu 13.04
#tuxmind.blogspot.com

#Add repo multiverse upgrade and install openjdk-7-jdk
sudo apt-get update && sudo apt-get upgrade -y
sudo software-properties-gtk -e multiverse && sudo apt-get update
sudo apt-get install -y openjdk-7-jdk

cd
#x86_64 or x86?
if [ `uname -m` == x86_64 ]
then

echo "Get url -> x86_64 version"
#Get url x86_64 version
ADT_BUNDLE_URL_x86_64=`curl -s http://developer.android.com/sdk/index.html | grep linux-x86_64 | cut -d\" -f2`
wget $ADT_BUNDLE_URL_x86_64 -O adt-bundle-linux.zip

else

echo "Get url -> x86 version"
#Get url x86 version
ADT_BUNDLE_URL_x86=`curl -s http://developer.android.com/sdk/index.html | grep linux-x86- | cut -d\" -f2`
wget $ADT_BUNDLE_URL_x86 -O adt-bundle-linux.zip

fi

unzip adt-bundle-linux.zip

#Copy eclipse icon
cp ~/adt-bundle-linux/eclipse/icon.xpm  ~/.local/share/icons/eclipse.xpm

#Create a .desktop entry file
cd ~/.local/share/applications
cat > android-adt.desktop << EOF
[Desktop Entry]
Type=Application
Name=Android ADT
GenericName=Android ADT-Bundle
Comment=Android Developer Tools
Exec=/home/$USER/adt-bundle-linux/eclipse/eclipse
Icon=eclipse
EOF

chmod +x ~/.local/share/applications/android-adt.desktop

#Shortcut on desktop (work in "Área de Trabalho" folder)
xdg-user-dir DESKTOP | sed 's/ /\\ /g' | xargs cp android-adt.desktop

cd

#Export path to .bashrc
grep "#Android SDK SCRIPT " ~/.bashrc || echo -e "#Android SDK SCRIPT \nexport PATH=\${PATH}:~/adt-bundle-linux/sdk/tools \nexport PATH=\${PATH}:~/adt-bundle-linux/sdk/platform-tools" >> ~/.bashrc

bash
exit


Algumas considerações importantes:
O script só foi testado no Ubuntu 13.04 (pode deixar de funcionar em futuras versões do Ubuntu)
Se a página web http://developer.android.com for alterada a variável ADT_BUNDLE_URL deixa de funcionar.
Última actualização do script 09/06/2013


segunda-feira, 6 de maio de 2013

terça-feira, 23 de abril de 2013

Mario Bros em ShellScript

Sempre achei o ShellScript uma excelente ferramenta. Mas nunca imaginei que o potencial do ShellScript pudesse ir tão longe.
E parabéns aos autores. O script está muito bem documentado,  e "legível".