Created
April 7, 2020 09:41
-
-
Save alex2844/b098e3a1cbb0014b07b159a71e2649fb to your computer and use it in GitHub Desktop.
Revisions
-
alex2844 created this gist
Apr 7, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,88 @@ #!/bin/sh if [ "$(id -u)" != "0" ]; then echo "This script must be run as root!" echo "Вы должны запускать программу имея права суперпользователя!" sleep 2 exit 1 fi grub_inst() { echo "#!/bin/sh exec tail -n +3 \$0 menuentry '$os_name' --class android-x86 { linux /droid/$os_name/kernel root=/dev/ram0 androidboot.hardware=android_x86 androidboot.selinux=permissive DATA=/data/ initrd /droid/$os_name/initrd.img }"> /etc/grub.d/40_custom echo "--------------------------------------------" echo "показываем содежимое файла /etc/grub.d/40_custom" cat /etc/grub.d/40_custom echo "--------------------------------------------" update-grub } inst_grub_customizer() { add-apt-repository ppa:danielrichter2007/grub-customizer apt-get update apt-get install grub-customizer } ls -t1 -i *.iso; ls -t1 -i *.iso |sed 's/^[ \t]*//'>tmp_1 echo "Введите номер нужного iso образа:" read _x grep -i $_x tmp_1 > tmp_2 _iso=`cat tmp_2 | cut -d" " -f2` rm tmp_1 tmp_2 echo "Используем образ: $_iso"; echo "Введите имя OS(это имя будет содержаться в GRUB2) иначе откажитесь n/no/н/нет:" read os_name case "$os_name" in n|no|н|нет|N|NO|Н|НЕТ|нинада ) exit;; * ) echo "Имя меню и папки: $os_name";; esac mkdir ./tmp /droid /droid/$os_name > /dev/null 2>&1 mkdir /droid/$os_name/data /droid/$os_name/system > /dev/null 2>&1 mount -o loop -t iso9660 $_iso ./tmp > /dev/null 2>&1 img_mount (){ mkdir ./tmp3 ./tmp_img > /dev/null 2>&1; echo "Ожидайте!"; cp -v ./tmp/system.img ./tmp_img/system.img e2fsck ./tmp_img/system.img mount -o loop -t ext4 ./tmp_img/system.img ./tmp3 } name_dir=`find ./tmp/system.*` name_=`basename $name_dir` if [ $name_ = "system.sfs" ] then echo "Образ Squashfs: $name_" mkdir ./tmp2 > /dev/null 2>&1; mount -t squashfs ./tmp/system.sfs ./tmp2 -o loop mkdir ./tmp3 > /dev/null 2>&1; mount -o loop -t ext4 ./tmp2/system.img ./tmp3 else echo "Образ img: $name_" img_mount fi; echo "Ожидайте!"; cp -avr ./tmp3/* /droid/$os_name/system > /dev/null 2>&1 cp -v ./tmp/initrd.img /droid/$os_name/initrd.img cp -v ./tmp/kernel /droid/$os_name/kernel cp -v ./tmp/ramdisk.img /droid/$os_name/ramdisk.img grub_inst grub-customizer> /dev/null 2>&1 if [ $? != 0 ] then echo "Возможно у вас не установлен grub-customizer !!"; read -p "Установить? (y/n)" choice case "$choice" in y|Y|да|ДА|Yes|YES|yes ) echo "Установка grub-customizer"; inst_grub_customizer; grub-customizer > /dev/null 2>&1;; * ) echo "Остановка";; esac fi umount ./tmp2 ./tmp3 ./tmp > /dev/null 2>&1 umount ./tmp2 ./tmp3 ./tmp > /dev/null 2>&1 sleep 2 rm -dr ./tmp ./tmp2 ./tmp3 ./tmp_img > /dev/null 2>&1 rm -dr ./tmp ./tmp2 ./tmp3 ./tmp_img > /dev/null 2>&1