Page 1 of 2
autoshutdown?? [Solved]
Posted: 20 Mar 2016, 05:26
by Ed_P
There is a /.config/autostart folder for scripts that automatically run when booting. Is there a similar idea for scripts to run when shutting down?
A Chrome module I am trying creates a very large cache folder which gets saved in my save.dat file. I would like to purge it when shutting down rather than save it.
Re: autoshutdown??
Posted: 20 Mar 2016, 12:24
by Bogomips
rc.local_shutdown, but not sure if executed before saving changes.
Re: autoshutdown??
Posted: 20 Mar 2016, 21:11
by Ed_P
Ok
Bogomips that is where I have it but it isn't working.
rc.local_shutdown
Code: Select all
#!/bin/sh
#
# rc.local_shutdown
#
# This script is executed at shutdown (rc0) and reboot (rc6).
# You need to make it executable before using.
#
# Example:
# /etc/rc.d/rc.samba stop
/home/guest/chromecache.sh
chromecache.sh
Code: Select all
#!/bin/sh
if [ -d "/home/guest/.cache/google-chrome/Default/Cache/" ]; then
rm /home/guest/.cache/google-chrome/Default/Cache/*
echo "Chrome cache purged."
else
echo "No Chrome cache."
fi
No echos when shutting down. And the script works in terminal mode. I'm missing something.
Re: autoshutdown??
Posted: 20 Mar 2016, 21:42
by tome
I think you can replace cache directory with symlink, for example symlink to /mnt/sda4/DefaultCache2 or to /mnt/ramd/cache (mkdir -p /mnt/ramd
mount ramdisk /mnt/ramd -t tmpfs -o size=105M
mkdir -p /mnt/ramd/cache
chown guest:guest /mnt/ramd/cache)
See at '/etc/changes-exit.conf' also.
Re: autoshutdown??
Posted: 20 Mar 2016, 22:03
by Ed_P
Well I found the problem with rc.local_shutdown, it needed to be made executable!!
http://forum.porteus.org/viewtopic.php? ... 696#p32711
Your symlink idea is interesting
tome. I was thinking of finding a way to redirect the chrome cache to the /tmp/ directory to solve the savedata space issue. And doing that would eliminate the concern of hundreds of thousands of .wh. files from all the cache deletes.
Re: autoshutdown??
Posted: 20 Mar 2016, 23:08
by Bogomips
@Ed Running in ram, and having not that much ram at my disposal, done more or less what you have in mind, within the guiexec script, for the PaleMoon cache:
Code: Select all
mkdir .cache/'moonchild productions'
sudo mount --bind /mnt/sda4/PaleMoon/moonchild .cache/'moonchild productions'
Re: autoshutdown??
Posted: 21 Mar 2016, 16:50
by Ed_P
hmmmm Not working for me.
Code: Select all
guest@porteus:~$ chrome.sh
mkdir: cannot create directory ‘/tmp/google-chrome/Cache/’: No such file or directory
sudo: invalid option -- '-'
usage: sudo [-D level] -h | -K | -k | -V
usage: sudo -v [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-u user
name|#uid]
usage: sudo -l[l] [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-U user
name] [-u user name|#uid] [-g groupname|#gid] [command]
usage: sudo [-AbEHknPS] [-C fd] [-D level] [-g groupname|#gid] [-p prompt] [-u
user name|#uid] [-g groupname|#gid] [VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-C fd] [-D level] [-g groupname|#gid] [-p prompt] [-u
user name|#uid] file ...
The part of the code failing:
Code: Select all
if [ ! -d /tmp/google-chrome/Cache ]; then
mkdir /tmp/google-chrome
mkdir /tmp/google-chrome/Cache
sudo mount --bind /tmp/google-chrome/Cache /home/guest/.cache/google-chrome/Default/Cache
fi
And
Code: Select all
guest@porteus:~$ ls /tmp
qtsingleapp-qlippe-2dfb-3e8= qtsingleapp-qlippe-2dfb-3e8-lockfile
guest@porteus:~$
But
Code: Select all
guest@porteus:~$ mkdir /tmp/google-chrome
guest@porteus:~$ mkdir /tmp/google-chrome/Cache
guest@porteus:~$ ls /tmp
google-chrome/ qtsingleapp-qlippe-2dfb-3e8-lockfile
qtsingleapp-qlippe-2dfb-3e8=
guest@porteus:~$ ls /tmp/google*
Cache/
guest@porteus:~$ sudo mount --bind /tmp/google-chrome/Cache /home/guest/.cache/google-chrome/Default/Cache
Password:
mount: mount point /home/guest/.cache/google-chrome/Default/Cache does not exist
guest@porteus:~$
The last error being understandable since chrome hasn't been run yet.
Re: autoshutdown??
Posted: 21 Mar 2016, 19:58
by Bogomips
Ed_P wrote:Code: Select all
if [ ! -d /tmp/google-chrome/Cache ]; then
mkdir /tmp/google-chrome
mkdir /tmp/google-chrome/Cache
sudo mount --bind /tmp/google-chrome/Cache /home/guest/.cache/google-chrome/Default/Cache
fi
Replace with:
Code: Select all
set -x; # Diagnostic output
if [ ! -d /tmp/google-chrome/Cache ]; then
mkdir -p /tmp/google-chrome/Cache; # Less chance of invisible chars creeping in
sudo mount --bind /tmp/google-chrome/Cache /home/guest/.cache/google-chrome/Default/Cache
fi
And let's see what we get.
Re: autoshutdown??
Posted: 21 Mar 2016, 20:48
by Ed_P
Bogomips wrote:And let's see what we get.
The results make no sense at all.
Code: Select all
guest@porteus:~$ ls /tmp
qtsingleapp-qlippe-2dfb-3e8= qtsingleapp-qlippe-2dfb-3e8-lockfile
guest@porteus:~$ chrome.sh
+ '[' '!' -d /tmp/google-chrome/Cache/ ']'
+ mkdir -p /tmp/google-chrome/Cache/
+ sudo --bind /tmp/google-chrome/Cache /home/guest/.cache/google-chrome/Default/Cache
sudo: invalid option -- '-'
usage: sudo [-D level] -h | -K | -k | -V
usage: sudo -v [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-u user
name|#uid]
usage: sudo -l[l] [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-U user
name] [-u user name|#uid] [-g groupname|#gid] [command]
usage: sudo [-AbEHknPS] [-C fd] [-D level] [-g groupname|#gid] [-p prompt] [-u
user name|#uid] [-g groupname|#gid] [VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-C fd] [-D level] [-g groupname|#gid] [-p prompt] [-u
user name|#uid] file ...
+ read
+ google-chrome-stable 'https://us.forgeofempires.com/page/ '
^C
guest@porteus:~$ ls /tmp
google-chrome/ qtsingleapp-qlippe-2dfb-3e8-lockfile
qtsingleapp-qlippe-2dfb-3e8=
guest@porteus:~$
I tried the mkdir -p option initially and had the same error, so I changed it to individual mkdirs. Now it works?? What does the set do? I have never seen it before.
Code: Select all
set -x; # Diagnostic output!!
if [ ! -d /tmp/google-chrome/Cache/ ]; then
mkdir -p /tmp/google-chrome/Cache/
sudo --bind /tmp/google-chrome/Cache /home/guest/.cache/google-chrome/Default/Cache
fi
Re: autoshutdown??
Posted: 21 Mar 2016, 21:49
by Bogomips
sudo mount -- bind 8)
-x shows step by step progress, a blow by blow account
btw your sudo ok? sudoers set and you don't have to submit pw?
Search for
set in
http://man.cx/bash
Re: autoshutdown??
Posted: 21 Mar 2016, 23:29
by Ed_P
Bogomips wrote:sudo mount -- bind 8)
I had mount originally. What the heck??
Will retest and get back to you.
Re: autoshutdown??
Posted: 22 Mar 2016, 05:31
by Ed_P
Ok, it seems to be working.
Code: Select all
guest@porteus:~$ chrome.sh
/mnt/sda5/porteus3.0/Modules/zchrome.xzm
Chrome ready to run. Press Enter when done using it.
+ '[' '!' -d /tmp/google-chrome/Cache/ ']'
+ mkdir -p /tmp/google-chrome/Cache/
+ sudo mount --bind /tmp/google-chrome/Cache /home/guest/.cache/google-chrome/Default/Cache
Password:Password:
mount: mount point /home/guest/.cache/google-chrome/Default/Cache does not exist
guest@porteus:~$ ls /tmp
google-chrome/ qtsingleapp-qlippe-2dfb-3e8-lockfile
qtsingleapp-qlippe-2dfb-3e8=
guest@porteus:~$ ls /tmp/google*
Cache/
guest@porteus:~$
But more questions.
How does one turn off the set -x command?
Would
Code: Select all
ln -sf /tmp/google-chrome/Cache /home/guest/.cache/google-chrome/Default/Cache
accomplish the same thing as the mount --bind command?
I need to reboot and retry this without the set -x command.
OK
Code: Select all
guest@porteus:~$ chrome.sh
/mnt/sda5/porteus3.0/Modules/zchrome.xzm
Chrome ready to run. Press Enter when done using it.
Password:Password:
mount: mount point /home/guest/.cache/google-chrome/Default/Cache does not exist
Password:
/mnt/sda5/porteus3.0/Modules/zchrome.xyzm
guest@porteus:~$ google-chrome/ qtsingleapp-qlippe-2dfb-3e8-lockfile
Re: autoshutdown??
Posted: 22 Mar 2016, 12:11
by Bogomips
Ed_P wrote:
How does one turn off the set -x command?
set
+x
Ed_P wrote:Would
Code: Select all
ln -sf /tmp/google-chrome/Cache /home/guest/.cache/google-chrome/Default/Cache
accomplish the same thing as the mount --bind command?
Which is better I was wondering. Sometimes I've found symlink not to work, so prefer to do mount. AFAIK magic folders also use the mount.
btw suggest enhancing by creating the cache directory:
Code: Select all
if [ ! -d /tmp/google-chrome/Cache ]; then
mkdir -p /tmp/google-chrome/Cache;
c=/home/guest/.cache/google-chrome/Default/Cache
[[ ! -d $c ]] && mkdir -p $c
sudo mount --bind /tmp/google-chrome/Cache $c
fi
Re: autoshutdown??
Posted: 22 Mar 2016, 15:21
by Ed_P
Bogomips wrote:Which is better I was wondering. Sometimes I've found symlink not to work, so prefer to do mount. AFAIK magic folders also use the mount.
The symlink I don't think would care if the .cache folder exists when executed. Not sure it also may not require sudo.
btw suggest enhancing by creating the cache directory:
Code: Select all
if [ ! -d /tmp/google-chrome/Cache ]; then
mkdir -p /tmp/google-chrome/Cache;
c=/home/guest/.cache/google-chrome/Default/Cache
[[ ! -d $c ]] && mkdir -p $c
sudo mount --bind /tmp/google-chrome/Cache $c
fi
Yes, a variable or two would help. And the && is an interesting approach also.
I've really enjoyed this thread
Bogomips. It's like the old days for me, asking questions and learning new things. Thank you.
Newest problem, running chrome I don't see anything in either cache location.
Re: autoshutdown??
Posted: 22 Mar 2016, 17:57
by Bogomips
Watch movie in browser and use:
which is what I used in order to find the PaleMoon cache.
Ed_P wrote:I've really enjoyed this thread
Bogomips. It's like the old days for me, asking questions and learning new things. Thank you.
I'm all for sharing knowledge and learning new things, myself included.