localhost ~ # #!/bin/bash
localhost ~ #
localhost ~ # # Change this to match your correct profile
localhost ~ # PROFILE="profiles.ini"
localhost ~ #
localhost ~ # cd "${HOME}/.mozilla/firefox"
localhost firefox #
localhost firefox # if test -z "$(mount | grep -F "${HOME}/.mozilla/firefox/${PROFILE}" )"
> then
> mount "${HOME}/.mozilla/firefox/${PROFILE}"
> fi
[mntent]: line 20 in /etc/fstab is bad
mount: mount point /root/.mozilla/firefox/profiles.ini is not a directory
localhost firefox #
localhost firefox # if test -f "${PROFILE}/.unpacked"
> then
> tar --exclude '.unpacked' -cpf packed.tmp.tar "$PROFILE"
> mv packed.tar packed.tar.old
> mv packed.tmp.tar packed.tar
> else
> tar xpf packed.tar &&\
> touch "${PROFILE}/.unpacked"
> fi
bash: : command not found
touch: cannot touch `profiles.ini/.unpacked': Not a directory

Howsabouts this?Enlight wrote:This is where you're wrong! profile is [something].default in ~/.mozilla/firefox/belikeyeshua wrote:localhost ~ # #!/bin/bash
localhost ~ # # Change this to match your correct profile
localhost ~ # PROFILE="profiles.ini"
Code: Select all
PROFDIR="${HOME}/.mozilla/firefox/"
PROFILE="${PROFDIR}/$(grep Path= "${PROFDIR}/profiles.ini" | cut -d = -f 2)"
Actually, the above is completely unnecessary, and rather silly really.Hopeless wrote:Howsabouts this?Enlight wrote:This is where you're wrong! profile is [something].default in ~/.mozilla/firefox/belikeyeshua wrote:localhost ~ # #!/bin/bash
localhost ~ # # Change this to match your correct profile
localhost ~ # PROFILE="profiles.ini"Assuming you only have one profile defined within profiles.ini...Code: Select all
PROFDIR="${HOME}/.mozilla/firefox/" PROFILE="${PROFDIR}/$(grep Path= "${PROFDIR}/profiles.ini" | cut -d = -f 2)"
Code: Select all
PROFILE="${HOME}/.mozilla/firefox/*.default/"Code: Select all
/bin/sh: /usr/bin/vi: No such file or directory
crontab: "/usr/bin/vi" exited with status 127
Code: Select all
#!/bin/bash
################################################################################################
## Firefox tmpfs utility
# see http://forums.gentoo.org/viewtopic-t-717117.html
#
# 1. check environment:
# a. entry in /etc/fstab
# b. profile dir is empty if not mounted tmpfs
# if either condition is false, print setup info
# 2. check pack direction:
# tmpfs is mounted
# pack it to archive
# tmpfs not mounted
# mount and unpack
#
################################################################################################
## Change this to match your correct profile
# If blank, this script will grab whatever profile is most recent
#
PROFILE=""
FFOX_HOME="${HOME}/.mozilla/firefox"
## Preferred compression utility
# We're going for speed, the options are: none, gzip or lzop
# If blank, the script will select lzop if available or default to gzip
#
COMPRESSOR=""
export GZIP='--fast' # option for gzip
## get more recent profile in home dir if not defined
#
if [[ ${PROFILE} == "" ]]; then
PROFILE=$( basename $( ls -rdt ${HOME}/.mozilla/firefox/*.default | tail -n 1 ) )
fi
## Check that environment is set up right
# a. We found the ffox profile
# b. There should be an entry in /etc/fstab
# c. The profile should be an empty directory if the tmps is unmounted
#
FAILED_CHECKS=0
if [[ ${PROFILE} == "" ]]; then
echo "Cannot find firefox profile directory"
exit 3
fi
if [[ $( grep "${FFOX_HOME}/${PROFILE}" /etc/fstab ) == "" ]]; then
FAILED_CHECKS=1
fi
if test -z "$(mount | grep -F "${FFOX_HOME}/${PROFILE}" )"; then
if [[ -d "${FFOX_HOME}/${PROFILE}" ]]; then
FAILED_CHECKS=$( ls ${FFOX_HOME}/${PROFILE}/* 2> /dev/null| wc -l )
fi
fi
if [[ ${FAILED_CHECKS} != 0 ]]; then
echo "See the Gentoo forums for an explanation of how this works: http://forums.gentoo.org/viewtopic-t-717117.html"
echo ""
echo "Make sure a line like this one is in /etc/fstab:"
GID=$( awk -v FS=: '/'"${USER}"'/{print $4 ; quit}' /etc/passwd )
echo "firefox ${FFOX_HOME}/${PROFILE} tmpfs noauto,user,exec,uid=${UID},gid=${GID} 0 0"
echo ""
echo "Exit firefox and tar a copy of the profile:"
echo " cd ${FFOX_HOME}"
echo " tar -czpf ${PROFILE}.tar.gz ${PROFILE} #(this is for gzip compression)"
echo " OR"
echo " tar -cp ${PROFILE} | lzop -c > ${PROFILE}.tar.lzo #(this is for lzop compression)"
echo " OR"
echo " tar -cpf ${PROFILE}.tar ${PROFILE} #(this is for no compression)"
echo "Back up your profile and create an empty directory:"
echo " mv -i ${PROFILE} ${PROFILE}.bak && mkdir ${PROFILE}"
exit 2
fi
## define how to pack archive
#
PACKLZO="tar --exclude '.unpackt' -C ${FFOX_HOME} -cp \"${PROFILE}\" | lzop -c > ${FFOX_HOME}/${PROFILE}.tar.lzo"
UNPACKLZO="lzop -cd \"${FFOX_HOME}/${PROFILE}.tar.lzo\" | tar -C ${FFOX_HOME} -xp"
PACKGZP="tar --exclude '.unpackt' -C ${FFOX_HOME} -czpf ${FFOX_HOME}/${PROFILE}.tar.gz \"${PROFILE}\""
UNPACKGZP="tar -C ${FFOX_HOME} -xzpf ${FFOX_HOME}/${PROFILE}.tar.gz"
PACKTAR="tar --exclude '.unpackt' -C ${FFOX_HOME} -cpf ${FFOX_HOME}/${PROFILE}.tar \"${PROFILE}\""
UNPACKTAR="tar -C ${FFOX_HOME} -xpf ${FFOX_HOME}/${PROFILE}.tar"
## set pack/unpack command based on available utilities
#
PACKCMD=""
UNPACKCMD=""
if [[ ${COMPRESSOR} == "" ]]; then
if [[ $( which lzop ) != "" ]] && [[ -f ${FFOX_HOME}/${PROFILE}.tar.lzo ]] ; then
PACKCMD=${PACKLZO}
UNPACKCMD=${UNPACKLZO}
else
PACKCMD=${PACKGZP}
UNPACKCMD=${UNPACKGZP}
fi
elif [[ ${COMPRESSOR} == "lzop" ]]; then
if test -z "which lzop"; then
echo "Could not find lzop"
exit 4
fi
elif [[ ${COMPRESSOR} == "gzip" ]]; then
PACKCMD=${PACKGZP}
UNPACKCMD=${UNPACKGZP}
elif [[ ${COMPRESSOR} == "none" ]]; then
PACKCMD=${PACKTAR}
UNPACKCMD=${UNPACKTAR}
fi
## Check mount point
#
if test -z "$(mount | grep -F "${FFOX_HOME}/${PROFILE}" )"; then
mount "${FFOX_HOME}/${PROFILE}"
if [[ $? != 0 ]]; then
echo "Failed to mount tmpfs"
exit 1
fi
fi
## Things look good, so pack if running profile found, or unpack if profile empty
#
if [[ -f "${FFOX_HOME}/${PROFILE}/.unpackt" ]]; then
echo -n "tarring firefox... "
START_TIME=$( date +%s )
bash -c "${PACKCMD}"
if [[ $? != 0 ]]; then
echo "Failed to pack the profile"
exit 4
fi
END_TIME=$( date +%s )
PACK_TIME=$(( ${END_TIME} - ${START_TIME} ))
echo "done in ${PACK_TIME} seconds!"
else
bash -c "${UNPACKCMD}"
echo "unpacking!"
if [[ $? != 0 ]]; then
echo "Failed to unpack the profile"
exit 5
fi
touch "${FFOX_HOME}/${PROFILE}/.unpackt"
fi
Code: Select all
bash -c "${UNPACKCMD}"Code: Select all
grep -m 1 ${USER} /etc/passwd | awk 'BEGIN{FS=":"}{print $4}'Code: Select all
awk -v FS=: '/'"${USER}"'/{print $4 ; quit}' /etc/passwdCode: Select all
id -gTo tell the truth, I'm not sure why either. If I try to execute it directly without wrapping bash around it, I get this error:truc wrote:I haven't read the whole script, but, I don't see why you launch a new bash process to execute eg "${UNPACKCMD}"
Code: Select all
$ packfox.sh
lzop: cannot use both `-c' and `-p'
Usage: lzop [-dxlthIVL19] [-qvcfFnNPkUp] [-o file] [-S suffix] [file..]
unpacking!Code: Select all
$ packfox.sh
packfox.sh: line 137: lzop -cd "/home/user/.mozilla/firefox/abcd1234.default.tar.lzo" | tar -C /home/user/.mozilla/firefox -xp: No such file or directoryOh yes, that is nice. I'll update the script.truc wrote:You can replace this:with:Code: Select all
grep -m 1 ${USER} /etc/passwd | awk 'BEGIN{FS=":"}{print $4}'Code: Select all
awk -v FS=: '/'"${USER}"'/{print $4 ; quit}' /etc/passwd

Code: Select all
#!/bin/bash
# Save this script as 'packfox' and hard/symlink it as 'packfox-daemon'
# (or the other way around) in the same dir.
# 'packfox' will invoke the packing.
# 'packfox-daemon' will run a loop, watching for changes, calling 'packfox' if any.
# both incantations will do checks, mounting, and unpacking.
# Change this to match your correct profile
PROFILE="bling"
PFDIR="${HOME}/.mozilla/firefox"
# Tar every .. seconds (regardless of changes)
TMOUT="900"
# But not more often than every .. seconds (regardless of changes)
TMMIN="60"
# Regex for which files not to act on when they're changed.
# Use inotifywait -m -e modify -e move -e create -e delete --exclude '(/Cache/)' -r your_profile_dir
# and do some browsing to determine which regex will be right for YOU.
IEXCL="(.sqlite-journal$)|(\-log.txt$)|(cookies.sqlite$)|(sessionstore\-[0-9].js$)|(/weave/)|(/Cache/)"
# Have you read everything and have you made the necessary adjustments? Then remove the line below ;-)
echo "I should read the comments and adjust the variables before running this script" && exit 2
# No user servicable parts below this line.
TGT="${PFDIR}/${PROFILE}"
function seppuku(){
echo "${1}"
exit 2
}
test -d "${PFDIR}" || seppuku "Profile dir doesn't exist"
if [ -z "$(mount -t tmpfs | grep -F "${TGT}" )" ]
then
mount "${PFDIR}/${PROFILE}" || seppuku "Mounting of profile's tmpfs failed; check fstab"
fi
test -f "${TGT}/.unpacked" || tar -xpf "${PFDIR}/packed.tar" -C "${PFDIR}" && touch "${TGT}/.unpacked"
if [ "$(basename ${0})" == "packfox-daemon" ]
then
which inotifywait >/dev/null 2>&1 || seppuku "Install sys-fs/inotify-tools first".
while true
do inotifywait -q -q -t ${TMOUT} -e modify -e move -e create -e delete --exclude "${IEXCL}" \
-r "${PFDIR}/${PROFILE}"; "$(dirname "${0}")/packfox"; sleep ${TMMIN}
done
exit
fi
cd "${PFDIR}"
tar --exclude '.unpacked' -cpf "${PFDIR}/packed.tmp.tar" "${PROFILE}"
mv "${PFDIR}/packed.tar" "${PFDIR}/packed.tar.old"
mv "${PFDIR}/packed.tmp.tar" "${PFDIR}/packed.tar"
googling for tmpfs osx ~brings this link: Blazing Fast Firefox using OSX RamDiskgigio wrote:Hi,
I'm very interested in this,
Could anyone please post the shell commands to run the script in Mac OS X 10.4 ?
I tried to follow all of your instructions, but i get this error when mounting tmpfs: "unknown special file or file system."
It probably has to do with fstab,
Anyone can help?
Thank you very much in advance
I also have a question regarding this post. Does the above mean that if you do not set CHOST, MAKEOPTS, GENTOO_MIRRORS etc, then they will leave unset for this specific package? Well, without GENTOO_MIRRORS you will not be able to even fetch itHopeless wrote:One thing to bear in mind is that variables in these files override what you may find in make.conf, rather than add to them, so if you have just 'CFLAGS="-O3"' in the above example ffmpeg will be compiled without any -march set.

If you don't override stuff on the commandline they will be taken from make.conf . If not found there, portage will leave them unset or, in some cases, make up something by itself.I also have a question regarding this post. Does the above mean that if you do not set CHOST, MAKEOPTS, GENTOO_MIRRORS etc, then they will leave unset for this specific package? Well, without GENTOO_MIRRORS you will not be able to even fetch it
Code: Select all
CFLAGS="-foobar" emerge --info
Code: Select all
emerge --info
Code: Select all
envCode: Select all
/usr/bin/which lsCode: Select all
PATH="/tmp" /usr/bin/which lsCode: Select all
export PATH="/tmp"So... if you create this /etc/portage/env/media-video/ffmpeg file and post there, say, CFLAGS="-O2 -march=k8", then will all the other variables, like CHOST, MAKEOPTS, GENTOO_MIRRORS be taken from /etc/make.conf, or will they be left unset. From the "One thing to bear in mind is that variables in these files override what you may find in make.conf, rather than add to them, so if you have just 'CFLAGS="-O3"' in the above example ffmpeg will be compiled without any -march set." I concluded that they will be left unset. Or maybe the files in /etc/portage/env are intended to be used for posting into them the CFLAGS variable only, and all the rest is taken from /etc/make.conf?Sure, tbh I can't even remember how/where I learned about it, but I know full well about the lack of documentation for this feature.
Take (for example) media-video/ffmpeg, if you have CFLAGS="-O2 -march=k8" in make.conf, but wish to have ffmpeg compiled with -O3, you'd create the file (and parent directories) '/etc/portage/env/media-video/ffmpeg', and simply add 'CFLAGS="-O3 -march=k8"' to it, basically the same format as make.conf, which is really just for setting shell variables.
That's basically all there is to it, and it has lots of uses, you can override many variables which you might set in make.conf, CFLAGS just being the most obvious one, but another fantastic one is EXTRA_ECONF, to which you can add extra --enable-foo or --disable-foo arguments to ./configure (presuming the ebuild uses econf).
One thing to bear in mind is that variables in these files override what you may find in make.conf, rather than add to them, so if you have just 'CFLAGS="-O3"' in the above example ffmpeg will be compiled without any -march set.
Another thing is not everything seems to work, one example of something which doesn't is ALSA_PCM_PLUGINS for media-libs/alsa-lib, and probably the same holds true for VIDEO_CARDS, LINGUAS and the like (run `emerge -v --info | grep USE_EXPAND` for a list), but most likely the reason for this is they are in fact just USE flags, and their real format is alsa_pcm_plugins_FOO, so adding alsa_pcm_plugins_rate and similar to /etc/portage/package.use should do the trick there.

Sorry I didn't reply sooner, updates to this thread weren't bumping it in my "egosearch".Ch00k wrote:boerKrelis, many thanks for your reply. Though, I actually mean the following:So... if you create this /etc/portage/env/media-video/ffmpeg file and post there, say, CFLAGS="-O2 -march=k8", then will all the other variables, like CHOST, MAKEOPTS, GENTOO_MIRRORS be taken from /etc/make.conf, or will they be left unset. From the "One thing to bear in mind is that variables in these files override what you may find in make.conf, rather than add to them, so if you have just 'CFLAGS="-O3"' in the above example ffmpeg will be compiled without any -march set." I concluded that they will be left unset. Or maybe the files in /etc/portage/env are intended to be used for posting into them the CFLAGS variable only, and all the rest is taken from /etc/make.conf?Sure, tbh I can't even remember how/where I learned about it, but I know full well about the lack of documentation for this feature.
Take (for example) media-video/ffmpeg, if you have CFLAGS="-O2 -march=k8" in make.conf, but wish to have ffmpeg compiled with -O3, you'd create the file (and parent directories) '/etc/portage/env/media-video/ffmpeg', and simply add 'CFLAGS="-O3 -march=k8"' to it, basically the same format as make.conf, which is really just for setting shell variables.
That's basically all there is to it, and it has lots of uses, you can override many variables which you might set in make.conf, CFLAGS just being the most obvious one, but another fantastic one is EXTRA_ECONF, to which you can add extra --enable-foo or --disable-foo arguments to ./configure (presuming the ebuild uses econf).
One thing to bear in mind is that variables in these files override what you may find in make.conf, rather than add to them, so if you have just 'CFLAGS="-O3"' in the above example ffmpeg will be compiled without any -march set.
Another thing is not everything seems to work, one example of something which doesn't is ALSA_PCM_PLUGINS for media-libs/alsa-lib, and probably the same holds true for VIDEO_CARDS, LINGUAS and the like (run `emerge -v --info | grep USE_EXPAND` for a list), but most likely the reason for this is they are in fact just USE flags, and their real format is alsa_pcm_plugins_FOO, so adding alsa_pcm_plugins_rate and similar to /etc/portage/package.use should do the trick there.
Sorry to post this in an unrelated thread, but I'm really concerned in learning this feature

Code: Select all
#!/bin/bash
/usr/local/bin/pack_ffox.sh
/usr/bin/firefox $*
/usr/local/bin/pack_ffox.sh
Code: Select all
#!/bin/bash
PROFDIR="${HOME}/.mozilla/firefox"
PROFILE="$(grep Path= "${PROFDIR}/profiles.ini" | cut -d = -f 2)"
cd "${HOME}/.mozilla/firefox"
if test -z "$(mount | grep -F "${HOME}/.mozilla/firefox/${PROFILE}" )"
then
mount "${HOME}/.mozilla/firefox/${PROFILE}"
fi
if test -f "${PROFILE}/.unpacked"
then
tar --exclude '.unpacked' -cpf packed.tmp.tar "$PROFILE"
mv packed.tar packed.tar.old
mv packed.tmp.tar packed.tar
else
tar xpf packed.tar &&\
touch "${PROFILE}/.unpacked"
fi