Hakchi:Variables and Functions

From hakchi
Jump to: navigation, search

There are a number of functions and variables available in hakchi for use in scripts.

Contents

Variables[edit source]

If you have a standalone script and would like to read one of these variables, /bin/hakchi get can be used with the variable name as the first parameter.

If you're in a preinit.d script, you can access the variable directly.

modname[edit source]

The name of the mod, this is set to hakchi

modpath[edit source]

The mod path, this is set to /$modname

mountpoint[edit source]

Depending on if the system is in preinit or normal boot, this can be one of two values, /newroot or nothing

installpath[edit source]

The location that hakchi is installed to, set to $mountpoint/var/lib/$modname

firmwarepath[edit source]

The location on nand that hakchi will search for the default hsqs image in, set to $installpath/firmware

extfirmwarepath[edit source]

The location on external storage that hakchi will search for the default hsqs image in, set to $mountpoint/media/$modname/firmware

rootfs[edit source]

The rootfs folder containing folders that get overmounted on top of the stock ones, set to $installpath/rootfs

squashfs[edit source]

A mount point containing the original squashfs image, set to $mountpoint/var/squashfs

preinit[edit source]

The location of the preinit loader file, set to $rootfs/etc/preinit

preinitpath[edit source]

The location of the preinit.d folder, set to $preinit.d

sftype[edit source]

The type of system currently booted, it can be one of two values: nes or snes

sfregion[edit source]

The region of the system currently booted, it can be one of the following values:

  • usa
  • eur
  • jpn

gamepath[edit source]

The location of the original game path that gets overmounted with the custom games

profilepath[edit source]

The location of the user profile containing save data among other things, set to /var/lib/clover/profiles/0

temppath[edit source]

The temporary directory, set to /tmp

Functions[edit source]

If you have a standalone script and would like to run one of these functions, /bin/hakchi can be used with the function name as the first parameter.

If you're in a preinit.d script, you can call the function directly.

b0010_functions[edit source]

b0010_functions contains general functions useful for hmods

squashDevice[edit source]

Prints the device that contains the squashfs filesystem.

mountSquash[edit source]

Mounts the squashfs to $squashfs

umountSquash[edit source]

Unmounts the squashfs from $squashfs

mount_base[edit source]

Mounts the user data partition at [[Hakchi:Variables and Functions#mountpoint|$mountpoint]/var/lib] and calls <code>mountSquash.

umount_base[edit source]

Unmounts the user data partition at [[Hakchi:Variables and Functions#mountpoint|$mountpoint]/var/lib] and calls <code>umountSquash .

remove_old[edit source]

mod_repair_etc[edit source]

mod_repair_modules[edit source]

mount_move[edit source]

remount_root[edit source]

checkFirmware[edit source]

currentFirmware[edit source]

overmountModules[edit source]

loadFirmware[edit source]

shutdown[edit source]

Unmounts everything and powers down the system.

reboot[edit source]

Unmounts everything and reboots the system.

early_getty[edit source]

Starts a shell on ttyS0 at 115200 baud and returns when the shell ends.

copy[edit source]

A helper function that calls rsync -ac $1 $2.

As the copy function also creates the destination directory if needed, there is no requirement to use the mkdir command to create an empty destination folder first.

copy_mask[edit source]

restore[edit source]

Repairs the directory specified using the original files from squashfs

mount_bind[edit source]

Unmounts the destination directory if there's already a mount point at that location and then runs mount -o bind "$1" "$2"

Usage: mount_bind source destination

overmount[edit source]

Uses mount_bind to overmount the specified directory from $rootfs onto the normal path used by the system or alternatively, you can specify an alternate destination directory.

Example 1: overmounts $rootfs/bin onto /bin

overmount "/bin"

Example 2: overmounts $rootfs/backgrounds onto /usr/share/backgrounds

overmount "/backgrounds" "/usr/share/backgrounds"

containsGames[edit source]

Checks if the specified directory exists and contains game folders, if success, return an exit code of 0 or otherwise, return an exit code of 1.

linkGames[edit source]

softwareCheck[edit source]

repair_fonts[edit source]

checkGamepath[edit source]

checkPath[edit source]

Checks for the existence of the path passed as the first argument and if it exists, prints the path and returns an exit code of 0

If the path doesn't exist, nothing will be printed and the function will return an exit code of 1

findGameSyncStorage[edit source]

Prints the base directory that games should be synced to.

findGameStorage[edit source]

Prints the path that is currently being used for the games or returns an exit code of 1 if no custom games are found.

overmount_games[edit source]

uilist[edit source]

Lists all processes currently using the display.

uikill[edit source]

Kills all processes currently using the display.

uistop[edit source]

Stops all processes currently using the display.

uistart[edit source]

Starts the Nintendo UI

uipause[edit source]

Suspends all processes using the display.

uiresume[edit source]

Resumes all processes using the display.

gameover[edit source]

Powers down the system.

printSoftwareInfo[edit source]

Prints the system type and region

stopTask[edit source]

Stops the specified process name and returns when the process has ended.

waitTask[edit source]

Waits until the specified process name is no longer running and returns.

showImage[edit source]

Displays the png image file passed as the first argument.

playSound[edit source]

Plays the wav sound file passed as the first argument.

hwmon[edit source]

An alias for cat "/sys/devices/virtual/hwmon/hwmon1/temp1_input"

usedBlockSpace[edit source]

Displays the number of 1024KB blocks used by the volume passed as the first argument.

freeBlockSpace[edit source]

Displays the remaining number of 1024KB blocks for the volume passed as the first argument.

usedSpace[edit source]

Prints the amount of space used by a folder.

usedBy[edit source]

A helper function that accepts one of the following variables and calls usedSpace with the corresponding path.

  • games
  • saves
  • mods
  • firmware

b0020_backup[edit source]

backup_one[edit source]

backup_nandb[edit source]

backup_nandc[edit source]

backup[edit source]

dumpFirmware[edit source]

b0030_package[edit source]

The functions in b0030_package are used during hmod installation and management.

transfer_file[edit source]

transfer_default[edit source]

transfer_path[edit source]

pack_upath[edit source]

pack_install[edit source]

pack_list[edit source]

pack_uninstall[edit source]

packs_install[edit source]

packs_uninstall[edit source]

b0040_usb[edit source]

disableUsbDevice[edit source]

switchToUsbDevice[edit source]

switchToUsbHost[edit source]

getUsbStorageIds[edit source]

waitForStorageDevice[edit source]

waitForUsbDevice[edit source]

waitForMmcDevice[edit source]

checkStorageDevice[edit source]

checkExtStorage[edit source]