Register
It is currently Fri Dec 19, 2014 5:14 am

[BASH4.1+][ANDROID] smoothing out my function library :)


All times are UTC - 6 hours


Post new topic Reply to topic  [ 1 post ] 
Author Message
 PostPosted: Wed Aug 07, 2013 2:21 pm   

Joined: Wed Aug 07, 2013 1:42 pm
Posts: 1
Been playing with the terminal on android for quite some time now, (its one of the easiest methods for controlling the device lol :p) & of cource, came to miss alot of functionality found on more
Full-fledged terminals, & needed functions for others.

But by the time i was done with my scripts, i had a few 100, & it was a pain to go through. So i made a library that can:
1.)Be linked using one of its (execution level) functions name & react as that function.
2.)still be called as an execution-level function (or any if debug is on).
3.)still be linked to another path using one of # names set by string, or its own name,
& react as home file
4.)Maintains order & doesnt lock up regardless of execution type
5.)can extend itself with 0 editing,
6.)Can detect any instigator, from: boot, script, shell, self, etc. & mode (Eg: source, or call),
& react accordingly based on a configuration
6.)Can detect all needed variables before execution, such as execution level, all partitions,
Customized busybox/toolbox settings, runtime variables, etc seamlessly before execution
Allowing for multi-device compatibility
7.)Can eccept configurations for most settings (both system (root) & user) in customizable path.
8.)Can be ran from anywhere, Eg: boot, recovery, system, etc.
9.)Can be moved to any path/name & have its own configuration(s) (multi-installable)

In a nutshell: its a multi-call shell script designed to react identical to busybox, for per-app usage, or be sourced for mass scripting (1 or more outside script with multiple/repetitive calls to main script.) Or terminal use.

Be warned, it is rather large, (~110kb)
Recommend sourcing for best use

Any tips on how i can optimize it and/or trim it, let me know

Main script (PasteBin):
Code:
http://pastebin.com/A8ALwtu2


Makeshift readme (PasteBin)
Code:
http://pastebin.com/5YDJDxC8


Typical configuration:
Code:
#======================================================================#
#                                         __                           #
#               Main configuration for:  /\ \                          #
#      ____  __  __  _____      __   _ __\ \ \____    ___   __  _      #
#     / ,__\/\ \/\ \/\  __`\  /'__`\/\`'__\ \ '__`\  / __`\/\ \/ \     #
#    /\__, `\ \ \_\ \ \ \_\ \/\  __/\ \ \/ \ \ \_\ \/\ \_\ \/>  </     #
#    \/\____/\ \____/\ \ ,__/\ \____\\ \_\  \ \_,__/\ \____//\_/\_\    #
#     \/___/  \/___/  \ \ \/  \/____/ \/_/   \/___/  \/___/ \//\/_/    #
#                      \ \_\    By: YupitsMine420                      #
#                       \/_/                                           #
#======================================================================#
# File definitions:                                                    #
# can use full path, or script variable to define. not read by default.#
#                                                                      #
# Prop_File: $LocalPath/SystemProps.cfg                                #
# BusyBox_File: $LocalPath/BusyBox_Add.cfg                             #
#                                                                      #
#  Specify custom BusyBox/ToolBox binaries for script to use           #
#                                                                      #
# Use_BusyBox: $System/stest/Data/bin/busybox1201                      #
# Use_ToolBox: $System/stest/Data/bin/toolbox                          #
#                                                                      #
#======================================================================#
#
# Permissions configurations
#
# Paths:
Perm_Src_Dir=755     # Source paths.
Perm_Cfg_Dir=644     # Configuration paths.
Perm_Bin_Dir=775     # Binary (executable) paths.
#
# Files:
Perm_Src_File=644    # Sourcable files.
Perm_Cfg_File=644    # Configuration files.
Perm_Bin_File=755    # Binary (executable) files.
#
DefOwner=root        # Default owner.
DefGroup=root        # Default group
#
#======================================================================#
#
# Basic configurations:
#
# User configuration path, should be R/W by default (usually '/data').
# Configurations in this path will override base configurations.
LocalPath='$Data/local/SuperBox'
#
Set scripts clock format, 0=12hr, 1=24hr.
use_24hr=1
#
# Scripts default log method, 0=disabled, 1=critical, 2=full.
LogMode=2
#
# sloggers default log method, '%' fits to width,'-' quiets output.
# (only outputs to log) only effects terminal.
LoggerMode=-
#
# Enable/Disable colors in all segments. 1=enable, 0=disable
ColorMode=1
#
# Specify default Colours for modes allowing colour. Format is:
# '0 1 2 3 4 5 6 7 8', where: 0=Error, 1=Note/Highlight, 2=Note2,
# 3=Normal, 4=File, 5=Path, 6=Link, 7=Background, 8=Borders.
DefaultColors=(1 3 6 2 6 4 5 0 5)
#
# Set how many decimal points to allow in arithmatic calculations,
# used in (most) filesize segments. Default value is "2"
# Set to '0' to disable float integers (round to closest full number)
MaxDec=2
#
Sets path used to store/load permissions configurations for 'm/lperm'
# these configurations are device specific & should not be ported or
# re-used outside of this ROM. Path set below should be constantly R/W.
PermDir="$LocalPath/Perms"
#
#======================================================================#
#
# SuperBox specific Configurations:
#
# Allow superbox to be called by cron (startup), 1=Enable, 0=Disable.
sbox_allow_boot=1
#
# specify if SuperBox requires administrator on launch.
sbox_need_admin=1
#
# Specify if date should be appended to log name when generating.
# string is manipulated with 'sbox_log_tag' variable
# With the default value of '%a-%h-%d_%H-%M'
sbox_log_usedate=0 ; sbox_log_tag='%a-%h-%d_%H-%M'
#
# Link names that will be treated as direct call to SuperBox, Eg:
# Wont be treated as execution mode.
sbox_null_links="sbox2 superbox sbox.old sbox.new"
#
#======================================================================#
#
# cd (icd) Configurations:
#
# Specify if 'cd' should check match path/name case-sensitively
# Default is '1' (true), should use '-c' instead of changing this.
icd_usecase=1
#
#======================================================================#
#
# alignapk (zipalign) configurations:
#
# Zip alignment configurations:
# Zip default alignment level, 0 = disabled, 1 = auto, 2 = forced.
align_level=2
#
# Use MD5 sum for each file when processing align. 1=true, 0=false
align_usemd5=0
#
# Use SQL table for storing data, 1 = true, 0 = text database
align_usesql=1
#
# SQL table name to store configurations
align_table=zipalign
#
#======================================================================#
#
# Other (Misc.) Configurations:
#


Tree configuration:
Code:
#======================================================================#
#                                         __                           #
#               Tree configuration for:  /\ \                          #
#      ____  __  __  _____      __   _ __\ \ \____    ___   __  _      #
#     / ,__\/\ \/\ \/\  __`\  /'__`\/\`'__\ \ '__`\  / __`\/\ \/ \     #
#    /\__, `\ \ \_\ \ \ \_\ \/\  __/\ \ \/ \ \ \_\ \/\ \_\ \/>  </     #
#    \/\____/\ \____/\ \ ,__/\ \____\\ \_\  \ \_,__/\ \____//\_/\_\    #
#     \/___/  \/___/  \ \ \/  \/____/ \/_/   \/___/  \/___/ \//\/_/    #
#                      \ \_\    By: YupitsMine420                      #
#                       \/_/                                           #
#======================================================================#
#
# Directories script will avoid, script supports partial matches when
# processing these paths. should be seperated by whitespace (" ").
# BadLink & BadFile variables can also be defined to ignore said entry
BadDirs=" /proc /dev /sys / "
#
# Force processing any input, even if entry exists in 'Bad*' variable
ForceP=0
#
#
# Used to connect same-depth paths when processing sub-directories &
# files, Default is "|", should be quoted.
Con="|"
#
# Used as padding for filenames/etc. to match depth.
Dep="+=> "
#
# Seperates file/link/date/size information when displaying tree.
Sep="-->"
#
# Specify how tree will process links when detected.
# 0 = Normal, 1 = Ignore link, 2 = ignore all (dont display).
LinkMode=0
#
# Enable to Display directory info/size & file/link/dir count, etc.
ShowInfo=True
#
# Enabling will stop script from processing more then 1 directory
# deep into base path.
NoRec=0
#
# Default Colormode for tree, Mode is '0 1 2 3 4 5 6 7 8 9' where:
# 0 = file, 1 = link, 2=directory, 3=note, 4=background, 5=connector,
# 6=depth, 7=seperator, 8=time, 9=size.
Color=(1 3 6 2 0 6 3 8 4)
#


-->script √
-->makeshift readme (including all functions & usage) √
-->typical configuration (with definitions) √
-->partial changelog


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP