diff options
author | madmonkey <madfkingmonkey@gmail.com> | 2017-10-02 02:55:45 +0300 |
---|---|---|
committer | madmonkey <madfkingmonkey@gmail.com> | 2017-10-08 14:54:27 +0300 |
commit | 78df6b1eee9d42b7e2244e422587a0726ba9d594 (patch) | |
tree | 1dfda5449736dc39f6295b144413d59fab38cabf | |
parent | acf7d64fd40154fde980ef9ca939e04e68b7ee6f (diff) |
script up
-rwxr-xr-x | bin/extractimg | 8 | ||||
-rwxr-xr-x | bin/makeimg | 10 | ||||
-rw-r--r-- | mod/hakchi/config | 2 | ||||
-rw-r--r-- | mod/hakchi/init | 13 | ||||
-rwxr-xr-x | mod/hakchi/rootfs/bin/chmenu | 21 | ||||
-rwxr-xr-x | mod/hakchi/rootfs/bin/gameover | 2 | ||||
-rwxr-xr-x | mod/hakchi/rootfs/bin/hakchi | 15 | ||||
-rwxr-xr-x | mod/hakchi/rootfs/bin/test-menu | 4 | ||||
-rwxr-xr-x | mod/hakchi/rootfs/bin/uistart | 2 | ||||
-rwxr-xr-x | mod/hakchi/rootfs/bin/uistop | 2 | ||||
-rw-r--r-- | mod/hakchi/rootfs/etc/preinit | 6 | ||||
-rw-r--r-- | mod/hakchi/rootfs/etc/preinit.d/b0000_defines | 6 | ||||
-rw-r--r-- | mod/hakchi/rootfs/etc/preinit.d/b0010_functions | 85 | ||||
-rw-r--r-- | mod/hakchi/rootfs/etc/preinit.d/b0020_backup (renamed from mod/hakchi/script/backup) | 34 | ||||
-rw-r--r-- | mod/hakchi/rootfs/etc/preinit.d/b0030_package (renamed from mod/hakchi/script/package) | 40 | ||||
-rw-r--r-- | mod/hakchi/rootfs/etc/preinit.d/p7000_preinit | 2 | ||||
-rw-r--r-- | mod/hakchi/rootfs/etc/preinit.d/p7080_hmods | 28 | ||||
-rw-r--r-- | mod/hakchi/rootfs/etc/preinit.d/pa100_games | 6 | ||||
-rw-r--r-- | mod/hakchi/script/install | 12 | ||||
-rw-r--r-- | mod/hakchi/script/reflash | 27 | ||||
-rw-r--r-- | mod/hakchi/script/transfer | 25 |
21 files changed, 244 insertions, 106 deletions
diff --git a/bin/extractimg b/bin/extractimg index 8d5d631..1b2a122 100755 --- a/bin/extractimg +++ b/bin/extractimg @@ -1,13 +1,13 @@ #!/bin/bash set -e -img=$1 +img="$1" if [ -z "$img" ]; then - img=./dump/kernel.img + img="./dump/kernel.img" fi -infile=$(basename "$img") -inpath=./$(basename "$infile" .img) +infile="$(basename "$img")" +inpath="./$(basename "$infile" .img)" rm -rf "$inpath" mkdir "$inpath" diff --git a/bin/makeimg b/bin/makeimg index 3718a5f..14c1e98 100755 --- a/bin/makeimg +++ b/bin/makeimg @@ -1,13 +1,13 @@ #!/bin/bash set -e -inpath=$1 +inpath="$1" if [ -z "$inpath" ]; then - inpath=./kernel + inpath="./kernel" fi -infile=$(basename "$inpath").img -img=./$infile +infile="$(basename "$inpath").img" +img="./$infile" rm -rf "$inpath/initramfs/hakchi" rsync -a "$inpath/../mod/" "$inpath/initramfs/" @@ -15,7 +15,7 @@ if [ "$2" == "notx" ]; then rm -rf "$inpath/initramfs/hakchi/transfer" fi upx -qq --best "$inpath/initramfs/sbin/cryptsetup" || true -(cd "$inpath/initramfs";find . -print0 | sort -z | cpio -0o -H newc -R root:root --quiet > ../initramfs.cpio) +(cd "$inpath/initramfs";find . -print0 | sort -z | cpio -0o -H newc -R root:root --quiet > "../initramfs.cpio") lzop --best -f -o "$inpath/$infile-ramdisk.gz" "$inpath/initramfs.cpio" mkbootimg \ diff --git a/mod/hakchi/config b/mod/hakchi/config index 91ce384..4efc5ca 100644 --- a/mod/hakchi/config +++ b/mod/hakchi/config @@ -1,4 +1,4 @@ local cf_backup_dummy='n' local cf_backup='n' local cf_backup_nandc='n' -local cf_shutdown='y' +local cf_shutdown='n' diff --git a/mod/hakchi/init b/mod/hakchi/init index e885e8e..3240667 100644 --- a/mod/hakchi/init +++ b/mod/hakchi/init @@ -5,12 +5,13 @@ echo local modname="hakchi" local modpath="/$modname" local mountpoint="/newroot" -local installpath -local firmwarepath -local rootfs -local preinit -local preinitpath -local gamepath +local installpath="" +local firmwarepath="" +local rootfs="" +local squashfs="" +local preinit="" +local preinitpath="" +local gamepath="" local temppath="/tmp" mkdir -p "$temppath" diff --git a/mod/hakchi/rootfs/bin/chmenu b/mod/hakchi/rootfs/bin/chmenu index 5ae4fdc..9f67d83 100755 --- a/mod/hakchi/rootfs/bin/chmenu +++ b/mod/hakchi/rootfs/bin/chmenu @@ -2,23 +2,23 @@ source /etc/preinit script_init -state_file=$installpath/menu +state_file="$installpath/menu" [ -z "$1" ] && exit 1 -[ -f "$state_file" ] && prev_code=$(cat "$state_file") || prev_code=000 +[ -f "$state_file" ] && prev_code="$(cat "$state_file")" || prev_code="000" [ "$1" == "$prev_code" ] && exit 1 -echo Switching to menu $1 +echo "Switching to menu $1" if [ "$1" == "000" ]; then - targetpath=$rootfs$gamepath + targetpath="$rootfs$gamepath" else - targetpath=$rootfs$gamepath/$1 + targetpath="$rootfs$gamepath/$1" fi [ -d "$targetpath" ] || exit 1 -echo $1 > "$state_file" +echo "$1" > "$state_file" -echo New directory: $targetpath +echo "New directory: $targetpath" if [ "$1" != "000" ]; then if [ -f "$rootfs$gamepath/title.fnt" ] && [ ! -f "$targetpath/title.fnt" ]; then @@ -29,9 +29,8 @@ if [ "$1" != "000" ]; then fi fi -pkill -KILL clover-mcp -pkill -KILL ReedPlayer-Clover +uistop +rm -rf /var/cache/clover overmount_games - -/etc/init.d/S81clover-mcp start +uistart diff --git a/mod/hakchi/rootfs/bin/gameover b/mod/hakchi/rootfs/bin/gameover new file mode 100755 index 0000000..4f82421 --- /dev/null +++ b/mod/hakchi/rootfs/bin/gameover @@ -0,0 +1,2 @@ +#!/bin/sh +exec hakchi "$(basename "$0")" ${1+"$@"} diff --git a/mod/hakchi/rootfs/bin/hakchi b/mod/hakchi/rootfs/bin/hakchi new file mode 100755 index 0000000..e3493b8 --- /dev/null +++ b/mod/hakchi/rootfs/bin/hakchi @@ -0,0 +1,15 @@ +#!/bin/sh +source /etc/preinit +script_init + +hakchi(){ + [ "$1" == "hakchi" ] && shift + if type "$1" | grep -q '^.* is a shell function$' 2>/dev/null; then + ${1+"$@"} + else + echo "no such function: $@" + return 1 + fi +} + +hakchi "$(basename "$0")" ${1+"$@"} diff --git a/mod/hakchi/rootfs/bin/test-menu b/mod/hakchi/rootfs/bin/test-menu new file mode 100755 index 0000000..d22b60b --- /dev/null +++ b/mod/hakchi/rootfs/bin/test-menu @@ -0,0 +1,4 @@ +#!/bin/sh +uistop 1>/dev/null 2>&1 +/opt/test/bin/test-menu </dev/null +uistart diff --git a/mod/hakchi/rootfs/bin/uistart b/mod/hakchi/rootfs/bin/uistart new file mode 100755 index 0000000..4f82421 --- /dev/null +++ b/mod/hakchi/rootfs/bin/uistart @@ -0,0 +1,2 @@ +#!/bin/sh +exec hakchi "$(basename "$0")" ${1+"$@"} diff --git a/mod/hakchi/rootfs/bin/uistop b/mod/hakchi/rootfs/bin/uistop new file mode 100755 index 0000000..4f82421 --- /dev/null +++ b/mod/hakchi/rootfs/bin/uistop @@ -0,0 +1,2 @@ +#!/bin/sh +exec hakchi "$(basename "$0")" ${1+"$@"} diff --git a/mod/hakchi/rootfs/etc/preinit b/mod/hakchi/rootfs/etc/preinit index a045225..34a26fe 100644 --- a/mod/hakchi/rootfs/etc/preinit +++ b/mod/hakchi/rootfs/etc/preinit @@ -3,11 +3,11 @@ rand(){ } source_parts(){ - [ -z "$temppath" ] && local temppath=/tmp + [ -z "$temppath" ] && local temppath="/tmp" mkdir -p "$temppath" - local script=$temppath/script_$(rand) + local script="$temppath/script_$(rand)" rm -f "$script" - local searchpath=$(dirname "$1") + local searchpath="$(dirname "$1")" [ -d "$searchpath" ] || return 1 for i in $(find "$searchpath" -maxdepth 1 -path "$1" | sort); do cat "$i" >> "$script" diff --git a/mod/hakchi/rootfs/etc/preinit.d/b0000_defines b/mod/hakchi/rootfs/etc/preinit.d/b0000_defines index 47c7273..1f76521 100644 --- a/mod/hakchi/rootfs/etc/preinit.d/b0000_defines +++ b/mod/hakchi/rootfs/etc/preinit.d/b0000_defines @@ -1,4 +1,4 @@ -set_gamepath(){ +setGamepath(){ local feck="$mountpoint/var/lib/clover/profiles/0/home-menu/save/system-save.json" if [ -f "$mountpoint/etc/clover/version/canoe" ]; then # echo "SNES gamepath" @@ -19,9 +19,9 @@ modpath="/$modname" installpath="$mountpoint/var/lib/$modname" firmwarepath="$installpath/firmware" rootfs="$installpath/rootfs" +squashfs="$installpath/squashfs" preinit="$rootfs/etc/preinit" preinitpath="$preinit.d" gamepath="" -set_gamepath +setGamepath temppath="/tmp" - diff --git a/mod/hakchi/rootfs/etc/preinit.d/b0010_functions b/mod/hakchi/rootfs/etc/preinit.d/b0010_functions index 2689c24..432e23b 100644 --- a/mod/hakchi/rootfs/etc/preinit.d/b0010_functions +++ b/mod/hakchi/rootfs/etc/preinit.d/b0010_functions @@ -20,7 +20,7 @@ remove_old(){ mod_repair_etc(){ remove_old "$rootfs" rm -f "$modpath/rootfs/etc/preinit.d/p0000_config" - chown -R 0:0 $modpath/ + chown -R 0:0 "$modpath/" local etc="$temppath/etc" rm -rf "$etc" @@ -41,36 +41,38 @@ mod_repair_modules(){ remount_root(){ [ -z "$(mount | grep -F loop)" ] || return 1 - local tmpmount=$modpath/var.tmp + local tmpmount="/var" mkdir -p "$tmpmount" mount --move "$mountpoint/var" "$tmpmount" umount "$mountpoint" - local loopfile=$tmpmount${1##$mountpoint/var} - mount -o loop,ro "$loopfile" "$mountpoint" || shutdown + local loopfile="$tmpmount${1##$mountpoint/var}" + mount -o loop,ro,noatime "$loopfile" "$mountpoint" || shutdown mount --move "$tmpmount" "$mountpoint/var" } load_firmware(){ [ -d "$firmwarepath" ] || return 0 - local firmware=$(find "$firmwarepath" -type f -name "*.hsqs" | sort | head -n 1) + local firmware="$(find "$firmwarepath" -type f -name "*.hsqs" | sort | head -n 1)" [ -f "$firmware" ] || return 0 mod_repair_modules remount_root "$firmware" || return 0 cryptsetup close root-crypt mod_repair_etc - if [ -d "$rootfs/lib/modules/$(uname -r)" ]; then - overmount "/lib/modules" - else - echo "no modules for loaded kernel $(uname -r)" + if [ ! -d "$mountpoint/lib/modules/$(uname -r)" ]; then + if [ -d "$rootfs/lib/modules/$(uname -r)" ]; then + overmount "/lib/modules" + else + echo "no modules for loaded kernel $(uname -r)" + fi fi - set_gamepath + setGamepath } shutdown(){ - echo shutting down... + echo "shutting down..." echo sync umount -a -r 2>/dev/null @@ -78,6 +80,15 @@ shutdown(){ while :;do sleep 1;:;done } +reboot(){ + echo "rebooting..." + echo + sync + umount -a -r 2>/dev/null + /bin/reboot -f + while :;do sleep 1;:;done +} + early_getty(){ cd "$modpath/transfer" getty -ni 115200 ttyS0 -l /bin/sh @@ -86,14 +97,14 @@ early_getty(){ copy(){ # we must create target directory - local dirname=$(dirname "$2") + local dirname="$(dirname "$2")" mkdir -p "$dirname" rsync -ac "$1" "$2" } copy_mask(){ # this function is unsafe, avoid spaces in filenames! - local dirname=$(dirname "$2") + local dirname="$(dirname "$2")" mkdir -p "$dirname" rsync -ac $1 "$2" } @@ -111,25 +122,55 @@ mount_bind(){ overmount(){ if [ "$#" == "1" ]; then - echo overmounting $1 + echo "overmounting $1" mount_bind "$rootfs$1" "$mountpoint$1" && return 0 fi if [ "$#" == "2" ]; then - echo overmounting $1 on $2 + echo "overmounting $1 on $2" mount_bind "$rootfs$1" "$mountpoint$2" && return 0 fi - echo overmounting failed + echo "overmounting failed" + return 1 +} + +containsGames(){ + [ -d "$1" ] || return 1 + [ -z "$(cd "$1";ls CLV-* 2>/dev/null)" ] && return 1 + return 0 } overmount_games(){ - local menu_code=000 - [ -f "$installpath/menu" ] && menu_code=$(cat "$installpath/menu") - [ -z "$menu_code" ] && menu_code=000 - echo menu code: $menu_code + local menu_code="000" + [ -f "$installpath/menu" ] && menu_code="$(cat "$installpath/menu")" + [ -z "$menu_code" ] && menu_code="000" + echo "menu code: $menu_code" if [ "$menu_code" != "000" ]; then - if [ -d "$rootfs$gamepath/$menu_code" ]; then + if containsGames "$rootfs$gamepath/$menu_code"; then overmount "$gamepath/$menu_code" "$gamepath" && return 0 + else + echo "no romz found at: $rootfs$gamepath/$menu_code" fi fi - overmount "$gamepath" + if containsGames "$rootfs$gamepath"; then + overmount "$gamepath" && return 0 + fi + echo "no romz found at: $rootfs$gamepath" + return 1 +} + +uistop(){ + killall -9 clover-mcp + killall -9 ReedPlayer-Clover + killall kachikachi + killall canoe-shvc + killall retroarch +} + +uistart(){ + uistop 1>/dev/null 2>&1 + /etc/init.d/S81clover-mcp start +} + +gameover(){ + poweroff } diff --git a/mod/hakchi/script/backup b/mod/hakchi/rootfs/etc/preinit.d/b0020_backup index 55f89ef..e10c2dc 100644 --- a/mod/hakchi/script/backup +++ b/mod/hakchi/rootfs/etc/preinit.d/b0020_backup @@ -1,34 +1,38 @@ backup_one(){ [ ! -f "$backuppath/$1.gz" ] || return 0 - echo backup $1 - dd if=/dev/$1 bs=128K | gzip > "$backuppath/$1.gz" + echo "backup $1" + dd "if=/dev/$1" bs=128K | gzip > "$backuppath/$1.gz" +} + +backup_nandb(){ + mkdir -p "$backuppath" + local nandb_filename="$(cat $mountpoint/etc/clover/boardtype)-$(cat $mountpoint/etc/clover/VERSION).hsqs" + if [ ! -f "$backuppath/$nandb_filename" ]; then + echo "backup $nandb_filename" + dd if=/dev/mapper/root-crypt bs=4k \ + count=$((($(hexdump -e '1/4 "%u"' -s $((0x28)) -n 4 /dev/mapper/root-crypt)+0xfff)/0x1000)) \ + > "$backuppath/$nandb_filename" + md5sum "$backuppath/$nandb_filename" > "$backuppath/$nandb_filename.md5" + fi } backup_nandc(){ [ "$cf_backup_nandc" == "y" ] || return 0 - local backuppath=$installpath/backup + local backuppath="$installpath/backup" [ ! -f "$backuppath/nandc.gz" ] || return 0 - backuppath=$modpath + backuppath="$modpath" backup_one nandc } backup(){ - local backuppath=$installpath/backup + local backuppath="$installpath/backup" if [ -f "$modpath/nandc.gz" ]; then - echo move nandc + echo "move nandc" mkdir -p "$backuppath" mv "$modpath/nandc.gz" "$backuppath/" fi [ "$cf_backup" == "y" ] || return 0 - mkdir -p "$backuppath" - local nandb_filename=$(cat $mountpoint/etc/clover/boardtype)-$(cat $mountpoint/etc/clover/VERSION).hsqs - if [ ! -f "$backuppath/$nandb_filename" ]; then - echo backup $nandb_filename - dd if=/dev/mapper/root-crypt bs=4k \ - count=$((($(hexdump -e '1/4 "%u"' -s $((0x28)) -n 4 /dev/mapper/root-crypt)+0xfff)/0x1000)) \ - > "$backuppath/$nandb_filename" - md5sum "$backuppath/$nandb_filename" > "$backuppath/$nandb_filename.md5" - fi + backup_nandb [ "$cf_backup_dummy" == "y" ] || return 0 backup_one nanda backup_one nandd diff --git a/mod/hakchi/script/package b/mod/hakchi/rootfs/etc/preinit.d/b0030_package index 68396ef..3c3894f 100644 --- a/mod/hakchi/script/package +++ b/mod/hakchi/rootfs/etc/preinit.d/b0030_package @@ -17,13 +17,15 @@ transfer_default(){ } transfer_path(){ - local transferpath=$1 + local transferpath="$1" chown -R 0:0 "$transferpath/" find "$transferpath/" -maxdepth 1 -type f -iname "readme.*" -delete find "$transferpath/" -maxdepth 1 -type f -iname "*.txt" -delete find "$transferpath/" -maxdepth 1 -type f -iname "*.md" -delete local docopy=y cd "$transferpath" + [ -d "./bin" ] && chmod 755 ./bin/* + [ -d "./etc/init.d" ] && chmod 755 ./etc/init.d/* transfer_file "$transferpath/install" || docopy=n cd "$transferpath" transfer_file "$transferpath/transfer" || docopy=n @@ -31,21 +33,21 @@ transfer_path(){ } pack_upath(){ - echo $installpath/hmod/uninstall-$(basename "$1" .hmod) + echo "$installpath/hmod/uninstall-$(basename "$1" .hmod)" } pack_install(){ - echo installing $(basename "$1" .hmod)... + echo "installing $(basename "$1" .hmod)..." if [ -f "$1" ]; then - local transferpath=$temppath/pack + local transferpath="$temppath/pack" rm -rf "$transferpath" mkdir -p "$transferpath" cd "$transferpath" && tar -xzf "$1" else - local transferpath=$1 + local transferpath="$1" fi transfer_path "$transferpath" - echo creating uninstall for $(basename "$1" .hmod)... + echo "creating uninstall for $(basename "$1" .hmod)..." echo >> "$transferpath/uninstall" echo "# auto-generated" >> "$transferpath/uninstall" cd "$transferpath" @@ -54,7 +56,7 @@ pack_install(){ find . -depth -mindepth 1 -type d -exec echo rmdir \"\$rootfs/{}\" + >> "$transferpath/uninstall" [ $(stat -c%s "$transferpath/uninstall") -gt 8 ] || rm -f "$transferpath/uninstall" cd / - local unfile=$(pack_upath "$1") + local unfile="$(pack_upath "$1")" if [ -f "$transferpath/uninstall" ]; then dos2unix -u "$transferpath/uninstall" sed -i "s#rmdir #rmdir --ignore-fail-on-non-empty #" "$transferpath/uninstall" @@ -63,23 +65,29 @@ pack_install(){ else rm -f "$unfile" fi - echo package $(basename "$1" .hmod) installed + echo "package $(basename "$1" .hmod) installed" +} + +pack_list(){ + if [ -d "$installpath/hmod" ]; then + for i in $(find "$installpath/hmod/" -maxdepth 1 -type f -name "uninstall-*" | sort); do + echo "${i##$installpath/hmod/uninstall-}" + done + fi } pack_uninstall(){ if [ "$1" == "all" ]; then - if [ -d "$installpath/hmod" ]; then - for i in $(find "$installpath/hmod/" -maxdepth 1 -type f -name "uninstall-*" | sort); do - pack_uninstall "$i" - done - fi + for i in $(pack_list); do + pack_uninstall "$i" + done else - local unfile=$(pack_upath "$1") + local unfile="$(pack_upath "$1")" if [ -f "$unfile" ]; then - echo uninstalling $(basename "$1" .hmod)... + echo "uninstalling $(basename "$1" .hmod)..." cd "$rootfs" transfer_file "$unfile" - echo package $(basename "$1" .hmod) uninstalled + echo "package $(basename "$1" .hmod) uninstalled" fi fi cd / diff --git a/mod/hakchi/rootfs/etc/preinit.d/p7000_preinit b/mod/hakchi/rootfs/etc/preinit.d/p7000_preinit index 6fb1793..18d36b2 100644 --- a/mod/hakchi/rootfs/etc/preinit.d/p7000_preinit +++ b/mod/hakchi/rootfs/etc/preinit.d/p7000_preinit @@ -5,5 +5,5 @@ if [ "$cfg_boot_stock" == "y" ]; then umount_base 2>/dev/null return 0 else - echo loading $modname + echo "loading $modname" fi diff --git a/mod/hakchi/rootfs/etc/preinit.d/p7080_hmods b/mod/hakchi/rootfs/etc/preinit.d/p7080_hmods new file mode 100644 index 0000000..ca3b93d --- /dev/null +++ b/mod/hakchi/rootfs/etc/preinit.d/p7080_hmods @@ -0,0 +1,28 @@ +local transferpath="$installpath/transfer" +if [ -d "$transferpath" ]; then + cd "$transferpath" + [ -f "$transferpath/earlybird" ] && source "$transferpath/earlybird" + rm -f "$transferpath/earlybird" + + [ -f "$transferpath/uninstall" ] && packs_uninstall $(cat "$transferpath/uninstall") + rm -f "$transferpath/uninstall" + + [ -f "$transferpath/hmod/uninstall" ] && packs_uninstall $(cat "$transferpath/hmod/uninstall") + rm -f "$transferpath/hmod/uninstall" + + packs_install "$transferpath" + + if [ -d "$transferpath/hmod" ]; then + packs_install "$transferpath/hmod" + rm -rf "$transferpath/hmod" + fi + + echo "transferring data..." + transfer_path "$transferpath" + echo + cd / + rm -rf "$transferpath" + save_config + reboot +fi +unset transferpath diff --git a/mod/hakchi/rootfs/etc/preinit.d/pa100_games b/mod/hakchi/rootfs/etc/preinit.d/pa100_games index 73cf771..d0df244 100644 --- a/mod/hakchi/rootfs/etc/preinit.d/pa100_games +++ b/mod/hakchi/rootfs/etc/preinit.d/pa100_games @@ -1,5 +1 @@ -if [ -z "$(ls $rootfs$gamepath/CLV-* 2>/dev/null)" ]; then - echo "no romz found" -else - overmount_games -fi +overmount_games diff --git a/mod/hakchi/script/install b/mod/hakchi/script/install index fdd3df9..9ca6806 100644 --- a/mod/hakchi/script/install +++ b/mod/hakchi/script/install @@ -1,24 +1,24 @@ mod_uninstall(){ - echo uninstalling $modname... + echo "uninstalling $modname..." rm -rf "$installpath" - echo done. + echo "done." shutdown } mod_repair(){ mod_repair_etc full - chmod 755 $modpath/rootfs/bin/* - chmod 755 $modpath/rootfs/etc/init.d/* + cd "$modpath/rootfs/bin" && chmod 755 * + cd "$modpath/rootfs/etc/init.d" && chmod 755 * + cd / copy "/bin/" "$rootfs/bin/" copy "/sbin/cryptsetup" "$rootfs/bin/cryptsetup" copy "$modpath/rootfs/" "$rootfs/" } mod_install(){ - echo installing $modname... + echo "installing $modname..." rm -rf "$rootfs" restore "/bin/" restore "/etc/" - restore "$gamepath/" mod_repair } diff --git a/mod/hakchi/script/reflash b/mod/hakchi/script/reflash new file mode 100644 index 0000000..a7beaef --- /dev/null +++ b/mod/hakchi/script/reflash @@ -0,0 +1,27 @@ +local firmware="$(find -type f -name "*.hsqs" | sort | head -n 1)" +if [ -f "$firmware" ]; then + umount_base + umount "$mountpoint" + + cryptsetup close root-crypt + cryptsetup open /dev/nandb root-crypt --type plain --cipher aes-xts-plain --key-file /key-file + + dd if=/dev/zero of=/dev/mapper/root-crypt bs=512 "seek=$(($(stat -c%s "$firmware")/512))" + dd "if=$firmware" of=/dev/mapper/root-crypt bs=512 + + cryptsetup close root-crypt + cryptsetup open /dev/nandb root-crypt --readonly --type plain --cipher aes-xts-plain --key-file /key-file + + mount -o ro,noatime /dev/mapper/root-crypt "$mountpoint" + + local tmk="$(pwd)/mkfs.txz" + if [ -f "$tmk"]; then + cd / && tar xJf "$tmk" + mount_bind "$mountpoint/lib" "/lib" +# /sbin/mkfs.ext4 -L data -m 0 /dev/nandc + mkfs.ext2 -L data -m 0 /dev/nandc + umount "/lib" + fi + + mount_base +fi diff --git a/mod/hakchi/script/transfer b/mod/hakchi/script/transfer index 0ec983c..237d2c4 100644 --- a/mod/hakchi/script/transfer +++ b/mod/hakchi/script/transfer @@ -1,7 +1,4 @@ -source "$modpath/script/backup" source "$modpath/script/install" -source "$modpath/script/package" -source "$modpath/script/games" backup_nandc mount_base @@ -11,17 +8,26 @@ source_config local transferpath="$modpath/transfer" +cd "$transferpath" + [ -f "$transferpath/earlybird" ] && source "$transferpath/earlybird" rm -f "$transferpath/earlybird" +if [ -d "$transferpath/reflash" ]; then + cd "$transferpath/reflash" + source "$modpath/script/reflash" + cd "$transferpath" + rm -rf "$transferpath/reflash" +fi + # transfer firmware, if any if [ -d "$transferpath/firmware" ]; then - local firmware=$(find "$transferpath/firmware" -type f -name "*.hsqs" | sort | head -n 1) + local firmware="$(find "$transferpath/firmware" -type f -name "*.hsqs" | sort | head -n 1)" if [ -f "$firmware" ]; then mkdir -p "$firmwarepath" - local firmware_name=$(basename "$firmware") + local firmware_name="$(basename "$firmware")" find "$firmwarepath" -type f -not -name "$firmware_name" -delete - echo transferring firmware... + echo "transferring firmware..." copy "$firmware" "$firmwarepath/" fi rm -rf "$transferpath/firmware" @@ -32,7 +38,7 @@ source_parts "$modpath/rootfs/etc/preinit.d/p????_*firmware*" # now we can do install/repair if [ -f "$preinit" ]; then - echo $modname already installed + echo "$modname already installed" mod_repair else mod_install @@ -50,12 +56,15 @@ if [ -d "$transferpath/hmod" ]; then fi if [ -d "$transferpath/games" ]; then + source "$modpath/script/games" transfer_games "$transferpath/games" rm -rf "$transferpath/games" fi -echo transferring data... +echo "transferring data..." transfer_path "$transferpath" +echo save_config [ "$cf_shutdown" != "y" ] || shutdown +echo |