@brokenman
Thanks for providing a template for rc script. However, selecting the code from bulletin board followed by pasting into terminal does not work owing to leading spaces being inserted along the way, as a result of which,
here file cannot detect end of text delimiter:
Code: Select all
root@porteus:/home/guest# mkdir -p /tmp/module/etc/rc.d/{init.d,rc4.d}
root@porteus:/home/guest# cat >> /tmp/module/etc/rc.d/init.d/rc.runme << EOF
> #!/bin/bash
>
> export MANPATH+=:/tmp/manpath
> echo "\$MANPATH" > /tmp/output.txt
> EOF
> chmod +x /tmp/module/etc/rc.d/init.d/rc.runme
> ln -s /etc/rc.d/init.d/rc.runme /tmp/module/etc/rc.d/rc4.d/99runatstart
> dir2xzm /tmp/module /tmp/test.xzm
> ^C
Have had to edit text to look like this:
Code: Select all
mkdir -p /tmp/module/etc/rc.d/{init.d,rc4.d}
cat >> /tmp/module/etc/rc.d/init.d/rc.runme << EOF
#!/bin/bash
export MANPATH+=:/tmp/manpath
echo "\$MANPATH" > /tmp/output.txt
EOF
chmod +x /tmp/module/etc/rc.d/init.d/rc.runme
ln -s /etc/rc.d/init.d/rc.runme /tmp/module/etc/rc.d/rc4.d/99runatstart
dir2xzm /tmp/module /tmp/test.xzm
Resulting in:
Code: Select all
root@porteus:/home/guest# mkdir -p /tmp/module/etc/rc.d/{init.d,rc4.d}
root@porteus:/home/guest# cat >> /tmp/module/etc/rc.d/init.d/rc.runme << EOF
> #!/bin/bash
>
> export MANPATH+=:/usr/share/man
> echo "\$MANPATH" > /tmp/output.txt
> EOF
root@porteus:/home/guest# chmod +x /tmp/module/etc/rc.d/init.d/rc.runme
root@porteus:/home/guest# ln -s /etc/rc.d/init.d/rc.runme /tmp/module/etc/rc.d/rc4.d/99runatstart
root@porteus:/home/guest# dir2xzm /tmp/module /tmp/test.xzm
Parallel mksquashfs: Using 1 processor
Creating 4.0 filesystem on /tmp/test.xzm, block size 262144.
[===============================================================================|] 1/1 100%
Exportable Squashfs 4.0 filesystem, xz compressed, data block size 262144
compressed data, compressed metadata, compressed fragments, compressed xattrs
duplicates are removed
Filesystem size 0.60 Kbytes (0.00 Mbytes)
...
root@porteus:/home/guest# activate /tmp/test.xzm
Updating shared library links: /sbin/ldconfig
root@porteus:/home/guest# cat /tmp/output.txt
/usr/local/man:/usr/man:/usr/share/man
root@porteus:/home/guest# echo $MANPATH
/usr/local/man:/usr/man
So, setting MANPATH environment variable upon module activation proves not to be a practical solution. Seems activation takes place in subshell, or in different shell, and user's MANPATH environmental variable remains untouched.
Going for heuristic solution:
Code: Select all
mkdir -p manmod/etc/rc.d/init.d
cp p10/Por/runman.sh manmod/etc/rc.d/init.d/rc.runman
chmod +x manmod/etc/rc.d/init.d/rc.runman
dir2xzm manmod manpage.xzm
activate manpage.xzm
runman.sh:
Code: Select all
#!/bin/bash
# Using non-existent English Language Directory 'en' in /usr/local/man to
# Bind to /usr/share/man 2015-09-09 20:05:27
# Flag this by creating directory 'flg' in /usr/share/man (not 2 letter language)
rum() {
#STOP
# If bound, unbind first of all
if [[ $1 == stop ]]; then [[ -d /usr/local/man/en/flg ]] &&
umount /usr/share/man && rmdir /usr/local/man/en;
# Unflag
[[ -d /usr/share/man/flg && ! -d /usr/local/man/en ]] && rmdir /usr/share/man/flg;
return;
fi
# START
# If not bound, create 'en' directory if non-existent and flag this.
if [[ ! -d /usr/local/man/en/flg ]]; then [[ ! -d /usr/local/man/en ]] &&
{ [[ ! -d /usr/share/man/flg ]] && mkdir /usr/share/man/flg;
mkdir /usr/local/man/en; }
[[ -d /usr/share/man/flg && ! -d /usr/local/man/en ]] && rmdir /usr/share/man/flg;
[[ -d /usr/share/man/flg ]] && mount --bind /usr/share/man /usr/local/man/en;
fi
m="Access Module ManPages by Modification of MANPATH environmental variable:"$'\n'MANPATH+=:/usr/share/man;
# Unbound: Just post Message (=> en Directory already Exists in /usr/local/man)
[[ ! -d /usr/local/man/en/flg ]] && Xdialog --left --msgbox "$m" 6 96;
}
rum $1
Robuster runman.sh 13-9-15
Code: Select all
#!/bin/bash
# Using non-existent English Language Directory 'en' in /usr/local/man to
# Bind to /usr/share/man 2015-09-09 20:05:27
# Flag this by creating directory 'flg' in /usr/share/man (not 2 letter language)
rum() {
#STOP
# If bound, decrement lock count 2015-09-13 22:10:38
if [[ $1 == stop && -d /usr/share/man/flg ]]; then read f g <<< $(echo /usr/share/man/flg/sem*);
[[ -f $f ]] && rm $f && return;
fi
# Fall Through if no Semaphore File -> Unbind
if [[ $1 == stop ]]; then [[ -d /usr/local/man/en/flg ]] &&
umount /usr/share/man && rmdir /usr/local/man/en;
# Unflag
[[ -d /usr/share/man/flg && ! -d /usr/local/man/en ]] && rmdir /usr/share/man/flg;
return;
fi
# START
# If not bound, create 'en' directory if non-existent and flag this.
if [[ ! -d /usr/local/man/en/flg ]]; then [[ ! -d /usr/local/man/en ]] &&
{ [[ ! -d /usr/share/man/flg ]] && mkdir /usr/share/man/flg;
mkdir /usr/local/man/en; }
[[ -d /usr/share/man/flg && ! -d /usr/local/man/en ]] && rmdir /usr/share/man/flg;
[[ -d /usr/share/man/flg ]] && mount --bind /usr/share/man /usr/local/man/en;
return; # After Setting Up 2015-09-13 21:33:48
fi
m="Access Module ManPages by Modification of MANPATH environmental variable:"$'\n'MANPATH+=:/usr/share/man;
# Unbound: Just post Message (=> en Directory already Exists in /usr/local/man)
[[ ! -d /usr/local/man/en/flg ]] && Xdialog --left --msgbox "$m" 6 96;
# Already Bound on Entry 2015-09-13 21:43:28
if [[ -d /usr/local/man/en/flg ]]; then read f g <<< $(echo /usr/local/man/en/flg/sem*);
c=${f#*/sem}; # Semaphore lock count
[[ ${f#*/sem} == "*" ]] && c=100; let c--; # Initialise to 99
touch /usr/share/man/flg/sem$c; # Create Semaphore
fi
}
rum $1
Running On:
Code: Select all
guest@porteus:~$ man dpkg
No manual entry for dpkg
checking network resources...
guest@porteus:~$ deactivate manpage.xzm
guest@porteus:~$ sudo rmdir /usr/local/man/en # Simulated Non-English Locale
guest@porteus:~$ activate manpage.xzm
guest@porteus:~$ man dpkg
guest@porteus:~$ deactivate manpage.xzm
guest@porteus:~$ man dpkg
No manual entry for dpkg
checking network resources...
guest@porteus:~$ activate manpage.xzm
guest@porteus:~$ man dpkg
guest@porteus:~$ deactivate manpage.xzm
guest@porteus:~$ man dpkg
No manual entry for dpkg
checking network resources...
# Both temporary directories now removed.
guest@porteus:~$ ls /usr/share/man/flg
/bin/ls: cannot access /usr/share/man/flg: No such file or directory
guest@porteus:~$ ls /usr/local/man/en
/bin/ls: cannot access /usr/local/man/en: No such file or directory
Afraid, fail to see point of having symbolic link of this nature:
Code: Select all
ln -s /etc/rc.d/init.d/rc.runman manmod/etc/rc.d/rc4.d/99runatstart
Update Edit: 13-9-15