Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
neurobin committed Mar 29, 2017
1 parent c96e281 commit 4d735f8
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions funcs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,15 @@ abs_path(){
fi
}

r_trim(){
# ^ char in $2 not supported (needs extra care).
echo "$1" |sed "s=[$2]*$=="
}

sanit_path(){
echo "$1" |sed -e 's=//*=/=g' -e 's=/$=='
}

fstab_path(){
local path=$1
local s=
Expand Down Expand Up @@ -326,7 +335,7 @@ insert_fsentry_fstab(){
}

remove_fsentry_fstab(){
local edit=$1
local edit="$1"
if [ "$edit" != "" ]; then
proc="proc $(fstab_path "${edit}proc") proc defaults 0 0"
sys="sysfs $(fstab_path "${edit}sys") sysfs defaults 0 0"
Expand All @@ -346,6 +355,7 @@ remove_fsentry_fstab(){
}

mount_fs(){
edit=$(sanit_path "$edit")/ #must have / at end
if [ "$edit" != "" ]; then
insert_fsentry_fstab
mount devtmpfs "${edit}"dev -t devtmpfs && msg_out 'mounted dev'
Expand All @@ -359,7 +369,12 @@ mount_fs(){

umount_fs(){
livedir=$(cat "$JLIVEdirF")
edit=${livedir+$livedir/}edit/
if [ "$livedir" = "" ]; then
edit=edit/
else
edit="$livedir/edit/"
fi
edit=$(sanit_path "$edit")/ #must have / at end
if mount |awk '{print $3}' |grep -qF "${edit}"proc; then
if umount "${edit}"proc || umount -lf "${edit}"proc ; then
msg_out "unmount proc success"
Expand Down Expand Up @@ -550,12 +565,11 @@ jlcd_start(){
err_out "directory doesn't exist: $livedir"
fi
done
livedir=$(sanit_path "$livedir")
liveconfigfile="$livedir/.config"
touch "$liveconfigfile"
chmod 777 "$liveconfigfile"
edit=$(abs_path "$livedir/edit")/ #must end with a slash
#we got a valid $edit now
insert_fsentry_fstab

set -a
if [ -f "$livedir/$JL_sconf" ]; then
Expand Down

0 comments on commit 4d735f8

Please sign in to comment.