Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Localized Live CD/USB hack

Lekensteyn Jun 8th, 2011 658 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. # http://askubuntu.com/q/47522/6969
  3. remove_other_lang=true
  4. cd "$(dirname "$(readlink -f "$0")")"
  5. bootcfg=
  6. [ -d isolinux ] && bootcfg=isolinux/isolinux.cfg
  7. [ -d syslinux ] && bootcfg=syslinux/syslinux.cfg
  8. if [ $(id -u) = 0 ]; then
  9.     echo "** WARNING: you're running this script as root **"
  10.     echo "The newly created file localized-init and directory locale-hack will be owned by root"
  11. fi
  12. if [ ! -s "$bootcfg" -o ! -s casper/filesystem.squashfs ]; then
  13.     echo "Please copy this file $0 to the root directory of the Live USB / CD"
  14.     exit 1
  15. fi
  16. read -p "Locale: " lang
  17. if ! apt-cache search 'language-pack-gnome-*' | grep -q "language-pack-gnome-$lang-base"; then
  18.     echo "The language package could not be found"
  19.     exit 1
  20. fi
  21. if [ ! -d locale-hack ]; then
  22.     chmod u+w .
  23.     mkdir locale-hack
  24.     chmod u+w locale-hack
  25. fi
  26. echo "Root permissions are required to mount the squashfs"
  27. mountpoint=$(sudo mktemp -d)
  28. sudo mount -o loop casper/filesystem.squashfs $mountpoint
  29. names=$(grep -E "Filename: pool/main/l/[^/]+/(language-pack-gnome-$lang|language-pack-gnome-${lang}-base|language-pack-$lang|language-pack-${lang})" \
  30.     $mountpoint/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_natty_main_binary-amd64_Packages \
  31.     | cut -d' ' -f2)
  32. sudo umount $mountpoint
  33. sudo rmdir $mountpoint
  34. if [ -n "$names" ]; then
  35.         remove_other_lang && rm -f locale-hack/*.deb
  36.     mirror=archive.ubuntu.com
  37.     host $lang.$mirror >/dev/null && mirror=$lang.$mirror
  38.     for item in $names; do
  39.         wget http://$mirror/ubuntu/$item -O locale-hack/$(basename $item)
  40.     done
  41.         printf "#!/bin/sh\ncp /cdrom/locale-hack/*.deb /var/cache/apt/archives && apt-get -y install language-pack-gnome-%s\nexec init\n" $lang > localized-init
  42.     chmod u+w $bootcfg
  43.     if grep -q 'init=/cdrom/localized-init' $bootcfg; then
  44.         sed "s,locale=\S*,locale=$lang," -i $bootcfg
  45.     else
  46.         sed "s,--,locale=$lang init=/cdrom/localized-init --," -i $bootcfg
  47.     fi
  48. else
  49.     echo "Language packs not found!"
  50. fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top