diff --git a/SETUP.cmd b/SETUP.cmd new file mode 100644 index 0000000..78e2350 --- /dev/null +++ b/SETUP.cmd @@ -0,0 +1,30 @@ +@echo off + +rem get registry key for windows developer mode +set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" +set VALUE_NAME=AllowDevelopmentWithoutDevLicense +FOR /F "tokens=2* skip=2" %%a in ('reg query "%KEY_NAME%" /v "%VALUE_NAME%"') do set ValueValue=%%b +if %ValueValue% neq 1 ( + echo Please Enable Windows Developer Mode in Settings + timeout 2 >nul + echo After that, press enter to continue + timeout 1 >nul + echo Opening Settings + timeout 4 >nul + start ms-settings:developers + pause +) +rem start install.sh +set current_dir=%~dp0 +pushd %current_dir% +if exist %current_dir%install.sh ( + wsl sudo ./install.sh +) else ( + rem for some reason this else is showing even the install.sh is exist + echo install.sh.sh not found + timeout 3 >nul +) +rem get uac confirm from sudo.vbs and then install appx-package +for /d %%a in ("%current_dir%msix_unpack\*") do set manifest=%%~fa%\AppxManifest.xml +"%current_dir%sudo.vbs" powershell Add-AppxPackage -Register '%manifest%' +pause \ No newline at end of file diff --git a/VARIABLES.sh b/VARIABLES.sh index ef73ae2..2ac1cb2 100644 --- a/VARIABLES.sh +++ b/VARIABLES.sh @@ -1,10 +1,22 @@ #!/bin/bash # Modify your variables here to corretly reference your directory and subdir -Root="/mnt/c/GAppsWSA" +# get current dir of this script +Root="$(pwd)" # Your Windows architecture, x64 or arm64 -Architecture="x64" +# get architecture based on wsl architecture +# its always same as windows afaik +Architecture=$(uname -m) +if [ $Architecture == 'x86_64' ]; then + Architecture="x64" +elif [ $Architecture == 'arm64' || +$Architecture == 'aarch64' ]; then + Architecture="ARM64" +else + echo "is your cpu 64 bit or arm64 ?" + exit +fi MiscRoot="$Root/misc" PropRoot="$MiscRoot/prop/$Architecture" diff --git a/apply.sh b/apply.sh index f713d65..b851e96 100644 --- a/apply.sh +++ b/apply.sh @@ -1,84 +1,85 @@ #!/bin/bash +# added quote mark ('"') for every variable so it wont be a problem if the path has space/whitespace . ./VARIABLES.sh echo "Copying build.prop for each image" -cp "$PropRoot/build_system_ext.prop" /mnt/system_ext/build.prop -cp "$PropRoot/build_system.prop" /mnt/system/build.prop -cp "$PropRoot/build_system.prop" /mnt/system/system/build.prop -cp "$PropRoot/build_product.prop" /mnt/product/build.prop -cp "$PropRoot/build_vendor.prop" /mnt/vendor/build.prop -cp "$PropRoot/build_vendor_odm.prop" /mnt/vendor/odm/etc/vendor.prop +cp "$PropRoot"/build_system_ext.prop /mnt/system_ext/build.prop +cp "$PropRoot"/build_system.prop /mnt/system/build.prop +cp "$PropRoot"/build_system.prop /mnt/system/system/build.prop +cp "$PropRoot"/build_product.prop /mnt/product/build.prop +cp "$PropRoot"/build_vendor.prop /mnt/vendor/build.prop +cp "$PropRoot"/build_vendor_odm.prop /mnt/vendor/odm/etc/vendor.prop echo "Copying GApps files to system..." -cp -f -a $GAppsOutputFolder/app/* $InstallDir/app -cp -f -a $GAppsOutputFolder/etc/* $InstallDir/etc -cp -f -a $GAppsOutputFolder/overlay/* $InstallDir/overlay -cp -f -a $GAppsOutputFolder/priv-app/* $InstallDir/priv-app -cp -f -a $GAppsOutputFolder/framework/* $InstallDir/framework +cp -f -a "$GAppsOutputFolder"/app/* "$InstallDir"/app +cp -f -a "$GAppsOutputFolder"/etc/* "$InstallDir"/etc +cp -f -a "$GAppsOutputFolder"/overlay/* "$InstallDir"/overlay +cp -f -a "$GAppsOutputFolder"/priv-app/* "$InstallDir"/priv-app +cp -f -a "$GAppsOutputFolder"/framework/* "$InstallDir"/framework echo "Applying root file ownership" -find $InstallDir/app -exec chown root:root {} &>/dev/null \; -find $InstallDir/etc -exec chown root:root {} &>/dev/null \; -find $InstallDir/overlay -exec chown root:root {} &>/dev/null \; -find $InstallDir/priv-app -exec chown root:root {} &>/dev/null \; -find $InstallDir/framework -exec chown root:root {} &>/dev/null \; -find $InstallDir/lib -exec chown root:root {} &>/dev/null \; -find $InstallDir/lib64 -exec chown root:root {} &>/dev/null \; +find "$InstallDir"/app -exec chown root:root {} &>/dev/null \; +find "$InstallDir"/etc -exec chown root:root {} &>/dev/null \; +find "$InstallDir"/overlay -exec chown root:root {} &>/dev/null \; +find "$InstallDir"/priv-app -exec chown root:root {} &>/dev/null \; +find "$InstallDir"/framework -exec chown root:root {} &>/dev/null \; +find "$InstallDir"/lib -exec chown root:root {} &>/dev/null \; +find "$InstallDir"/lib64 -exec chown root:root {} &>/dev/null \; echo "Setting directory permissions" -find $InstallDir/app -type d -exec chmod 755 {} \; -find $InstallDir/etc -type d -exec chmod 755 {} \; -find $InstallDir/overlay -type d -exec chmod 755 {} \; -find $InstallDir/priv-app -type d -exec chmod 755 {} \; -find $InstallDir/framework -type d -exec chmod 755 {} \; -find $InstallDir/lib -type d -exec chmod 755 {} \; -find $InstallDir/lib64 -type d -exec chmod 755 {} \; +find "$InstallDir"/app -type d -exec chmod 755 {} \; +find "$InstallDir"/etc -type d -exec chmod 755 {} \; +find "$InstallDir"/overlay -type d -exec chmod 755 {} \; +find "$InstallDir"/priv-app -type d -exec chmod 755 {} \; +find "$InstallDir"/framework -type d -exec chmod 755 {} \; +find "$InstallDir"/lib -type d -exec chmod 755 {} \; +find "$InstallDir"/lib64 -type d -exec chmod 755 {} \; echo "Setting file permissions" -find $InstallDir/app -type f -exec chmod 644 {} \; -find $InstallDir/overlay -type f -exec chmod 644 {} \; -find $InstallDir/priv-app -type f -exec chmod 644 {} \; -find $InstallDir/framework -type f -exec chmod 644 {} \; -find $InstallDir/lib -type f -exec chmod 644 {} \; -find $InstallDir/lib64 -type f -exec chmod 644 {} \; -find $InstallDir/etc/permissions -type f -exec chmod 644 {} \; -find $InstallDir/etc/default-permissions -type f -exec chmod 644 {} \; -find $InstallDir/etc/preferred-apps -type f -exec chmod 644 {} \; -find $InstallDir/etc/sysconfig -type f -exec chmod 644 {} \; +find "$InstallDir"/app -type f -exec chmod 644 {} \; +find "$InstallDir"/overlay -type f -exec chmod 644 {} \; +find "$InstallDir"/priv-app -type f -exec chmod 644 {} \; +find "$InstallDir"/framework -type f -exec chmod 644 {} \; +find "$InstallDir"/lib -type f -exec chmod 644 {} \; +find "$InstallDir"/lib64 -type f -exec chmod 644 {} \; +find "$InstallDir"/etc/permissions -type f -exec chmod 644 {} \; +find "$InstallDir"/etc/default-permissions -type f -exec chmod 644 {} \; +find "$InstallDir"/etc/preferred-apps -type f -exec chmod 644 {} \; +find "$InstallDir"/etc/sysconfig -type f -exec chmod 644 {} \; echo "Applying SELinux security contexts to directories" -find $InstallDir/app -type d -exec chcon --reference=$InstallDir/app {} \; -find $InstallDir/overlay -type d -exec chcon --reference=$InstallDir/overlay {} \; -find $InstallDir/priv-app -type d -exec chcon --reference=$InstallDir/priv-app {} \; -find $InstallDir/framework -type d -exec chcon --reference=$InstallDir/framework {} \; -find $InstallDir/lib -type d -exec chcon --reference=$InstallDir/lib {} \; -find $InstallDir/lib64 -type d -exec chcon --reference=$InstallDir/lib64 {} \; -find $InstallDir/etc/permissions -type d -exec chcon --reference=$InstallDir/etc/permissions {} \; -find $InstallDir/etc/default-permissions -type d -exec chcon --reference=$InstallDir/etc/permissions {} \; -find $InstallDir/etc/preferred-apps -type d -exec chcon --reference=$InstallDir/etc/permissions {} \; -find $InstallDir/etc/sysconfig -type d -exec chcon --reference=$InstallDir/etc/sysconfig {} \; +find "$InstallDir"/app -type d -exec chcon --reference="$InstallDir"/app {} \; +find "$InstallDir"/overlay -type d -exec chcon --reference="$InstallDir"/overlay {} \; +find "$InstallDir"/priv-app -type d -exec chcon --reference="$InstallDir"/priv-app {} \; +find "$InstallDir"/framework -type d -exec chcon --reference="$InstallDir"/framework {} \; +find "$InstallDir"/lib -type d -exec chcon --reference="$InstallDir"/lib {} \; +find "$InstallDir"/lib64 -type d -exec chcon --reference="$InstallDir"/lib64 {} \; +find "$InstallDir"/etc/permissions -type d -exec chcon --reference="$InstallDir"/etc/permissions {} \; +find "$InstallDir"/etc/default-permissions -type d -exec chcon --reference="$InstallDir"/etc/permissions {} \; +find "$InstallDir"/etc/preferred-apps -type d -exec chcon --reference="$InstallDir"/etc/permissions {} \; +find "$InstallDir"/etc/sysconfig -type d -exec chcon --reference="$InstallDir"/etc/sysconfig {} \; echo "Applying SELinux security contexts to files" -find $InstallDir/framework -type f -exec chcon --reference=$InstallDir/framework/ext.jar {} \; -find $InstallDir/overlay -type f -exec chcon --reference=$InstallDir/app/CertInstaller/CertInstaller.apk {} \; -find $InstallDir/app -type f -exec chcon --reference=$InstallDir/app/CertInstaller/CertInstaller.apk {} \; -find $InstallDir/priv-app -type f -exec chcon --reference=$InstallDir/priv-app/Shell/Shell.apk {} \; -find $InstallDir/lib -type f -exec chcon --reference=$InstallDir/lib/libcap.so {} \; -find $InstallDir/lib64 -type f -exec chcon --reference=$InstallDir/lib64/libcap.so {} \; -find $InstallDir/etc/permissions -type f -exec chcon --reference=$InstallDir/etc/fs_config_dirs {} \; -find $InstallDir/etc/default-permissions -type f -exec chcon --reference=$InstallDir/etc/fs_config_dirs {} \; -find $InstallDir/etc/preferred-apps -type f -exec chcon --reference=$InstallDir/etc/fs_config_dirs {} \; -find $InstallDir/etc/sysconfig -type f -exec chcon --reference=$InstallDir/etc/fs_config_dirs {} \; +find "$InstallDir"/framework -type f -exec chcon --reference="$InstallDir"/framework/ext.jar {} \; +find "$InstallDir"/overlay -type f -exec chcon --reference="$InstallDir"/app/CertInstaller/CertInstaller.apk {} \; +find "$InstallDir"/app -type f -exec chcon --reference="$InstallDir"/app/CertInstaller/CertInstaller.apk {} \; +find "$InstallDir"/priv-app -type f -exec chcon --reference="$InstallDir"/priv-app/Shell/Shell.apk {} \; +find "$InstallDir"/lib -type f -exec chcon --reference="$InstallDir"/lib/libcap.so {} \; +find "$InstallDir"/lib64 -type f -exec chcon --reference="$InstallDir"/lib64/libcap.so {} \; +find "$InstallDir"/etc/permissions -type f -exec chcon --reference="$InstallDir"/etc/fs_config_dirs {} \; +find "$InstallDir"/etc/default-permissions -type f -exec chcon --reference="$InstallDir"/etc/fs_config_dirs {} \; +find "$InstallDir"/etc/preferred-apps -type f -exec chcon --reference="$InstallDir"/etc/fs_config_dirs {} \; +find "$InstallDir"/etc/sysconfig -type f -exec chcon --reference="$InstallDir"/etc/fs_config_dirs {} \; echo "Applying SELinux policy" # Sed will remove the SELinux policy for plat_sepolicy.cil, preserve policy using cp -cp $InstallDir/etc/selinux/plat_sepolicy.cil $InstallDir/etc/selinux/plat_sepolicy_new.cil -sed -i 's/(allow gmscore_app self (process (ptrace)))/(allow gmscore_app self (process (ptrace)))\n(allow gmscore_app self (vsock_socket (read write create connect)))\n(allow gmscore_app device_config_runtime_native_boot_prop (file (read)))/g' $InstallDir/etc/selinux/plat_sepolicy_new.cil -cp $InstallDir/etc/selinux/plat_sepolicy_new.cil $InstallDir/etc/selinux/plat_sepolicy.cil -rm $InstallDir/etc/selinux/plat_sepolicy_new.cil +cp "$InstallDir"/etc/selinux/plat_sepolicy.cil "$InstallDir"/etc/selinux/plat_sepolicy_new.cil +sed -i 's/(allow gmscore_app self (process (ptrace)))/(allow gmscore_app self (process (ptrace)))\n(allow gmscore_app self (vsock_socket (read write create connect)))\n(allow gmscore_app device_config_runtime_native_boot_prop (file (read)))/g' "$InstallDir"/etc/selinux/plat_sepolicy_new.cil +cp "$InstallDir"/etc/selinux/plat_sepolicy_new.cil "$InstallDir"/etc/selinux/plat_sepolicy.cil +rm "$InstallDir"/etc/selinux/plat_sepolicy_new.cil # Prevent android from using cached SELinux policy -echo '0000000000000000000000000000000000000000000000000000000000000000' > $InstallDir/etc/selinux/plat_sepolicy_and_mapping.sha256 +echo '0000000000000000000000000000000000000000000000000000000000000000' > "$InstallDir"/etc/selinux/plat_sepolicy_and_mapping.sha256 echo "!! Apply completed !!" diff --git a/extend_and_mount_images.sh b/extend_and_mount_images.sh index f5a8b15..136d8dd 100644 --- a/extend_and_mount_images.sh +++ b/extend_and_mount_images.sh @@ -1,53 +1,54 @@ #!/bin/bash +# added quote mark ('"') for every variable so it wont be a problem if the path has space/whitespace . ./VARIABLES.sh echo "chk product.img" -e2fsck -f $ImagesRoot/product.img +e2fsck -f "$ImagesRoot"/product.img echo "Resizing product.img" -resize2fs $ImagesRoot/product.img 240M +resize2fs "$ImagesRoot"/product.img 240M echo "chk system.img" -e2fsck -f $ImagesRoot/system.img +e2fsck -f "$ImagesRoot"/system.img echo "Resizing system.img" -resize2fs $ImagesRoot/system.img 1280M +resize2fs "$ImagesRoot"/system.img 1280M echo "chk system_ext.img" -e2fsck -f $ImagesRoot/system_ext.img +e2fsck -f "$ImagesRoot"/system_ext.img echo "Resizing system_ext.img" -resize2fs $ImagesRoot/system_ext.img 108M +resize2fs "$ImagesRoot"/system_ext.img 108M echo "chk vendor.img" -e2fsck -f $ImagesRoot/vendor.img +e2fsck -f "$ImagesRoot"/vendor.img echo "Resizing vendor.img" -resize2fs $ImagesRoot/vendor.img 300M +resize2fs "$ImagesRoot"/vendor.img 300M echo "Creating mount point for product" -mkdir -p $MountPointProduct +mkdir -p "$MountPointProduct" echo "Creating mount point for system_ext" -mkdir -p $MountPointSystemExt +mkdir -p "$MountPointSystemExt" echo "Creating mount point for system" -mkdir -p $MountPointSystem +mkdir -p "$MountPointSystem" echo "Creating mount point for vendor" -mkdir -p $MountPointVendor +mkdir -p "$MountPointVendor" echo "Mounting product" -mount -o rw $ImagesRoot/product.img $MountPointProduct +mount -o rw "$ImagesRoot"/product.img $MountPointProduct echo "Mounting system_ext" -mount -o rw $ImagesRoot/system_ext.img $MountPointSystemExt +mount -o rw "$ImagesRoot"/system_ext.img $MountPointSystemExt echo "Mounting system" -mount -o rw $ImagesRoot/system.img $MountPointSystem +mount -o rw "$ImagesRoot"/system.img $MountPointSystem echo "Mounting vendor" -mount -o rw $ImagesRoot/vendor.img $MountPointVendor +mount -o rw "$ImagesRoot"/vendor.img $MountPointVendor echo "!! Images mounted !!" \ No newline at end of file diff --git a/extract_gapps_pico.sh b/extract_gapps_pico.sh index af0c195..a266ad8 100644 --- a/extract_gapps_pico.sh +++ b/extract_gapps_pico.sh @@ -1,39 +1,40 @@ #!/bin/bash +# added quote mark ('"') for every variable so it wont be a problem if the path has space/whitespace . ./VARIABLES.sh -rm -rf $GAppsOutputFolder -rm -rf $GAppsTmpFolder -rm -rf $GAppsExtractFolder +rm -rf "$GAppsOutputFolder" +rm -rf "$GAppsTmpFolder" +rm -rf "$GAppsExtractFolder" -mkdir -p $GAppsOutputFolder -mkdir -p $GAppsTmpFolder -mkdir -p $GAppsExtractFolder +mkdir -p "$GAppsOutputFolder" +mkdir -p "$GAppsTmpFolder" +mkdir -p "$GAppsExtractFolder" echo "Unzipping OpenGApps" -for file in "$GAppsRoot/"*.zip; do unzip -q "$file" -d $GAppsExtractFolder; done +for file in "$GAppsRoot"/*.zip; do unzip -q "$file" -d "$GAppsExtractFolder"; done echo "Extracting Core Google Apps" -for f in "$GAppsExtractFolder/Core/"*.lz; do tar --lzip -xvf "$f" -C $GAppsTmpFolder &>/dev/null; done +for f in "$GAppsExtractFolder"/Core/*.lz; do tar --lzip -xvf "$f" -C "$GAppsTmpFolder" &>/dev/null; done echo "Extracting Google Apps" -for f in "$GAppsExtractFolder/GApps/"*.lz; do tar --lzip -xvf "$f" -C $GAppsTmpFolder &>/dev/null; done +for f in "$GAppsExtractFolder"/GApps/*.lz; do tar --lzip -xvf "$f" -C "$GAppsTmpFolder" &>/dev/null; done echo "Deleting duplicates & conflicting apps" -rm -rf "$GAppsTmpFolder/setupwizardtablet-x86_64" # We already have setupwizard "default" -rm -rf "$GAppsTmpFolder/packageinstallergoogle-all" # The image already has a package installer, and we are not allowed to have two. +rm -rf "$GAppsTmpFolder"/setupwizardtablet-x86_64 # We already have setupwizard "default" +rm -rf "$GAppsTmpFolder"/packageinstallergoogle-all # The image already has a package installer, and we are not allowed to have two. echo "Merging folders" -for D in $GAppsTmpFolder/*; do [ -d "${D}" ] && cp -r ${D}/* $GAppsOutputFolder; done +for D in "$GAppsTmpFolder"/*; do [ -d "${D}" ] && cp -r "${D}"/* "$GAppsOutputFolder"; done echo "Merging subfolders" -for D in $GAppsOutputFolder/*; do [ -d "${D}" ] && cp -r ${D}/* $GAppsOutputFolder && rm -rf ${D}; done +for D in "$GAppsOutputFolder"/*; do [ -d "${D}" ] && cp -r "${D}"/* "$GAppsOutputFolder" && rm -rf ${D}; done echo "Post merge operation" -cp -r $GAppsOutputFolder/product/* $GAppsOutputFolder && rm -rf "$GAppsOutputFolder/product"; +cp -r "$GAppsOutputFolder"/product/* "$GAppsOutputFolder" && rm -rf "$GAppsOutputFolder"/product; echo "Deleting temporary files" -rm -rf $GAppsTmpFolder -rm -rf $GAppsExtractFolder +rm -rf "$GAppsTmpFolder" +rm -rf "$GAppsExtractFolder" echo "!! GApps folder ready !!" diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..0c52d2f --- /dev/null +++ b/install.sh @@ -0,0 +1,98 @@ +#!/bin/bash +function loading_spinner() { + local pid=$! + local spin='-\|/' + local i=0 + while kill -0 $pid 2>/dev/null + do + i=$(( (i+1) %4 )) + printf "\r${spin:$i:1}" + sleep .1 + done +} +function convertPath() { + #convert path to WSL(linux) Format and add (/mnt) + #remove ("); lowercase disk letter; remove (:); change (\) to (/); add ("/mnt) to first line; add (") to last line + #input example ("C:/Windows") output ("/mnt/c/Windows") + echo $(sed 's/"//g; s/^\(.\{1\}\)/\L&\E/; s/://; s/\\/\//g; s/^/\/mnt\//; s/$//' <<<"$1") +} +function check_unzip_lzip() { + if [ ! command -v unzip &> /dev/null || + ! command -v lzip &> /dev/null || + ! command -v pv &> /dev/null ]; then + echo "unzip and/or lzip could not be found" + echo "Installing" + sudo apt install unzip lzip -y + fi +} +function createUnpackDir() { + if [ ! -d "$UNPACK_DIR" ]; then + echo "Creating $UNPACK_DIR" + mkdir "$UNPACK_DIR" + fi +} + +check_unzip_lzip +#get all variable from VARIABLES.sh +. ./VARIABLES.sh + +#ask user to input the path to the MsixBundle and OpenGapps.zip +clear +read -rp "Enter MsixBundle PATH (drag here or copy as path): " MsixBundlePath +read -rp "Enter OpenGapps.zip PATH (drag here or copy as path): " OpenGappsPath +clear + +echo "!! You got $Architecture CPU !!" +echo "----------------" + +# start +UNPACK_DIR=$Root/msix_unpack +createUnpackDir + +# set msixbundle var and opengapps var +MsixBundlePath=$(convertPath "$MsixBundlePath") +MsixBundleName=`basename "$MsixBundlePath"` +OpenGappsPath=$(convertPath "$OpenGappsPath") +OpenGappsName=`basename "$OpenGappsPath"` + +echo "Extracting ${Architecture} WsaPackage from $MsixBundleName" +unzip -joq "$MsixBundlePath" "WsaPackage_*_${Architecture}_*" -d "$UNPACK_DIR" & loading_spinner + +# set extracted WsaPackage var +WsaPackagePath=$(find "$UNPACK_DIR"/WsaPackage_*_${Architecture}_*) +WsaPackageName=`basename "$WsaPackagePath"` +WsaPackageUnpackDir=$UNPACK_DIR/${WsaPackageName%.*} +WsaPackageExclude=".AppxMetadata .[Content_Types].xml .AppxBlockMap.xml .AppxSignature.p7x" + +echo "Extracting $WsaPackageName" +unzip -oq "$WsaPackagePath" -d "$WsaPackageUnpackDir" & loading_spinner + +echo "Remove $MsixBundleName" +rm -rf "$UNPACK_DIR/$WsaPackageName" + +echo "Remove Metadata and other in $WsaPackageName" +rm -rf "$WsaPackageUnpackDir/AppxMetadata" +rm -rf "$WsaPackageUnpackDir/[Content_Types].xml" +rm -rf "$WsaPackageUnpackDir/AppxBlockMap.xml" +rm -rf "$WsaPackageUnpackDir/AppxSignature.p7x" + +echo "Copy $OpenGappsName" +cp "$OpenGappsPath" "$GAppsRoot" + +echo "Moving .img file to $ImagesRoot" +mv "$WsaPackageUnpackDir"/*.img "$ImagesRoot" + +# run script +echo "----------------" +. ./extract_gapps_pico.sh +echo "----------------" +. ./extend_and_mount_images.sh +echo "----------------" +. ./apply.sh +echo "----------------" +. ./unmount_images.sh +echo "----------------" + +echo "Moving .img file Back to $WsaPackageUnpackDir" +mv "$ImagesRoot"/*img "$WsaPackageUnpackDir" +# if all done, the terminal should back to cmd diff --git a/sudo.vbs b/sudo.vbs new file mode 100644 index 0000000..237b36e --- /dev/null +++ b/sudo.vbs @@ -0,0 +1,19 @@ +Option Explicit +If WScript.Arguments.Count = 0 Then + WScript.Echo "Usage: sudo program [arg1 arg2 ...]" & vbCrLf & _ + "Run `program` with paramators as root in new console window" +Else + Dim ShellApp, WshShell + Dim cmd, varg, i + Set WshShell = CreateObject("WScript.Shell") + cmd = WshShell.ExpandEnvironmentStrings("%COMSPEC%") + 'Build paramator + varg = "/C CD " & WshShell.CurrentDirectory & " & " + For i = 0 To WScript.Arguments.Count - 1 + varg = varg & " " & WScript.Arguments(i) + Next + varg = varg & " & PAUSE" + 'run cmd /C ... as root + Set ShellApp = CreateObject("Shell.Application") + ShellApp.ShellExecute cmd, varg, "", "runas" +End If \ No newline at end of file diff --git a/unmount_images.sh b/unmount_images.sh index 7b0ef6d..6d09d82 100644 --- a/unmount_images.sh +++ b/unmount_images.sh @@ -1,17 +1,18 @@ #!/bin/bash +# added quote mark ('"') for every variable so it wont be a problem if the path has space/whitespace . ./VARIABLES.sh echo "Unmounting product.img" -umount $MountPointProduct +umount "$MountPointProduct" echo "Unmounting system_ext.img" -umount $MountPointSystemExt +umount "$MountPointSystemExt" echo "Unmounting system.img" -umount $MountPointSystem +umount "$MountPointSystem" echo "Unmounting vendor.img" -umount $MountPointVendor +umount "$MountPointVendor" echo "!! Unmounting completed !!" \ No newline at end of file