Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # http://askubuntu.com/q/47522/6969
- remove_other_lang=true
- cd "$(dirname "$(readlink -f "$0")")"
- bootcfg=
- [ -d isolinux ] && bootcfg=isolinux/isolinux.cfg
- [ -d syslinux ] && bootcfg=syslinux/syslinux.cfg
- if [ $(id -u) = 0 ]; then
- echo "** WARNING: you're running this script as root **"
- echo "The newly created file localized-init and directory locale-hack will be owned by root"
- fi
- if [ ! -s "$bootcfg" -o ! -s casper/filesystem.squashfs ]; then
- echo "Please copy this file $0 to the root directory of the Live USB / CD"
- exit 1
- fi
- read -p "Locale: " lang
- if ! apt-cache search 'language-pack-gnome-*' | grep -q "language-pack-gnome-$lang-base"; then
- echo "The language package could not be found"
- exit 1
- fi
- if [ ! -d locale-hack ]; then
- chmod u+w .
- mkdir locale-hack
- chmod u+w locale-hack
- fi
- echo "Root permissions are required to mount the squashfs"
- mountpoint=$(sudo mktemp -d)
- sudo mount -o loop casper/filesystem.squashfs $mountpoint
- names=$(grep -E "Filename: pool/main/l/[^/]+/(language-pack-gnome-$lang|language-pack-gnome-${lang}-base|language-pack-$lang|language-pack-${lang})" \
- $mountpoint/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_natty_main_binary-amd64_Packages \
- | cut -d' ' -f2)
- sudo umount $mountpoint
- sudo rmdir $mountpoint
- if [ -n "$names" ]; then
- remove_other_lang && rm -f locale-hack/*.deb
- mirror=archive.ubuntu.com
- host $lang.$mirror >/dev/null && mirror=$lang.$mirror
- for item in $names; do
- wget http://$mirror/ubuntu/$item -O locale-hack/$(basename $item)
- done
- 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
- chmod u+w $bootcfg
- if grep -q 'init=/cdrom/localized-init' $bootcfg; then
- sed "s,locale=\S*,locale=$lang," -i $bootcfg
- else
- sed "s,--,locale=$lang init=/cdrom/localized-init --," -i $bootcfg
- fi
- else
- echo "Language packs not found!"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement