autoshutdown?? [Solved]

Post here if you are a new Porteus member and you're looking for some help.
User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Re: autoshutdown??

Post#16 by Ed_P » 22 Mar 2016, 19:27

Good news, bad news.

The ln command doesn't require a password prompt. :good:

The ln command doesn't direct the .cache file to the /tmp folder. :(

I found the chrome cache files. :good: They were where they were suppose to be. Why they didn't show up the last time I looked I have no idea. :unknown:

The chrome cache purge shutdown script works when shutting down. :Yahoo!:

There are no .wh. files resulting from deleting the cache files when shutting down. :shock: :Bravo: :good:

:beer:

BTW My code changes.

Code: Select all

CCACHE=/home/guest/.cache/google-chrome/Default/Cache
TCACHE=/tmp/google-chrome/Cache/
#set -x;  # Diagnostic output on!!

if [ ! -d $TCACHE ]; then
   mkdir -p $TCACHE
   [[ ! -d $CCACHE ]] && mkdir -p $CCACHE
   sudo mount --bind $TCACHE $CCACHE  
#   ln -sf   $TCACHE   $CCACHE
fi 
set +x;  # Diagnostic output off!!
Have to see if they switch the cache location. But at this point not as critical as before. And if it does work and I save the change when I shutdown I won't have to reply to the password prompt all the time. :good:


My full script invokes sudo 3 times and thru 3 password prompts. Normally if a script requires 1 password prompt I use ktsuss for the whole run but with chrome google doesn't allow chrome to be run in root mode. Is there a command that allows running a command in guest mode? Kind of a reverse sudo?
Ed

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Re: autoshutdown??

Post#17 by Ed_P » 22 Mar 2016, 21:36

:wall: :wall: :wall: :wall:

So, I manually execute the build and bind of the /tmp cache then ran chrome to see if the /tmp cache was working as planned and it is working. :good:

Unfortunately the .cache one is also. :shock: So instead of a 43.8MB cache I have 2 43.8MB caches. :evil:

:wall: :wall: :wall: :wall:
Ed

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Re: autoshutdown??

Post#18 by Ed_P » 22 Mar 2016, 23:34

Tried the symlink option again but unable to get it to work. :fool:

Code: Select all

ln -t  /home/guest/.cache/google-chrome/Default/Cache  /tmp/google-chrome/Cache
ln     /tmp/google-chrome/Cache  /home/guest/.cache/google-chrome/Default/Cache
ln -sf /tmp/google-chrome/Cache  /home/guest/.cache/google-chrome/Default/Cache
ln -sf /tmp/google-chrome/Cache  /home/guest/.cache/google-chrome/Default/Cache/*
ln -sf /tmp/google-chrome/Cache/ /home/guest/.cache/google-chrome/Default/Cache/
:pardon:
Ed

Bogomips
Full of knowledge
Full of knowledge
Posts: 2564
Joined: 25 Jun 2014, 15:21
Distribution: 3.2.2 Cinnamon & KDE5
Location: London

Re: autoshutdown??

Post#19 by Bogomips » 22 Mar 2016, 23:42

Ed_P wrote:Unfortunately the .cache one is also. :shock: So instead of a 43.8MB cache I have 2 43.8MB caches. :evil:
Rest assured there can only be one!

Create a sign file in the /tmp cache directory, and it should also show in the home cache directory :wink:
Ed_P wrote:Is there a command that allows running a command in guest mode? Kind of a reverse sudo?
super Was looking into this for wacojohn, before the whole whacko episode. :( Fine tuning of your root command. Usage in my notes somewhere. Anyway have a look at the man page after activating package.
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Re: autoshutdown??

Post#20 by Ed_P » 23 Mar 2016, 06:28

Bogomips wrote:Rest assured there can only be one!

Create a sign file in the /tmp cache directory, and it should also show in the home cache directory :wink:
Ok, did that the file replicated in the .cache folder, which to me appears to be duplication.
super Was looking into this for wacojohn, before the whole whacko episode. :( Fine tuning of your root command. Usage in my notes somewhere. Anyway have a look at the man page after activating package.
Interesting.

But I think I've found a better approach.

Code: Select all

CCACHE=/home/guest/.cache/google-chrome/Default/Cache
TCACHE=/tmp/google-chrome/Cache/
#set -x;  # Diagnostic output on!!

if [ ! -d $TCACHE ]; then
   echo /tmp
   mkdir -p $TCACHE
#   [[ ! -d $CCACHE ]] && mkdir -p $CCACHE
#   sudo mount --bind $TCACHE $CCACHE  
#   ln -sf   $TCACHE   $CCACHE
fi 
set +x;  # Diagnostic output off!!

echo Chrome
google-chrome-stable   --disk-cache-dir=$TCACHE   "https://us.forgeofempires.com/page/ " > /dev/null 2>&1 &
And if I can control the cache I can move the chrome.xzm module from the optional folder to the modules folder and eliminate the activate/deactivate functions of the script and their sudo prompts. :Bravo:

Just need to find the shortcut to Chrome in the Porteus menu to tweak it.

Thanks for sticking with me on this Bogomips. :beer: :beer:
Ed

Bogomips
Full of knowledge
Full of knowledge
Posts: 2564
Joined: 25 Jun 2014, 15:21
Distribution: 3.2.2 Cinnamon & KDE5
Location: London

Re: autoshutdown??

Post#21 by Bogomips » 23 Mar 2016, 13:08

Ed_P wrote:
Bogomips wrote:Ok, did that the file replicated in the .cache folder, which to me appears to be duplication.
Quite the opposite - Unification! Two separate directories have now become one. :twisted:
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Re: autoshutdown??

Post#22 by Ed_P » 23 Mar 2016, 18:23

Some interesting comments I found when reading about the mount command.

Code: Select all

One can also mount an already visible directory tree elsewhere:
       mount --bind olddir newdir

The mount(8) command internally uses udev symlinks, so use
the symlinks in /etc/fstab has no advantage  over  LABEL=/UUID=.

       The non-superuser mounts.
              Normally,  only  the  superuser can mount filesystems.  However,
              when fstab contains the user option on a line, anybody can mount
              the corresponding system.

              Thus, given a line

                     /dev/cdrom  /cd  iso9660  ro,user,noauto,unhide

              any  user  can  mount  the iso9660 filesystem found on his CDROM
 
It would seem that the mount command I was using should have been:

Code: Select all

sudo mount --bind $CCACHE $TCACHE 
to match the olddir/newdir sequence.

Anyways, I think I can make this thread solved at this point. Thanks again for all your help Bogomips. I really appreciate it. :friends:
Ed

Bogomips
Full of knowledge
Full of knowledge
Posts: 2564
Joined: 25 Jun 2014, 15:21
Distribution: 3.2.2 Cinnamon & KDE5
Location: London

Re: autoshutdown??

Post#23 by Bogomips » 23 Mar 2016, 19:26

Ed_P wrote:It would seem that the mount command I was using should have been:

Code: Select all

sudo mount --bind $CCACHE $TCACHE 
to match the olddir/newdir sequence.
It's been done right all along! This final conclusion is erroneous. The directory that must exist is the one in /tmp. That comes first, as it is where all the downloaded stuff goes. The mount point comes second, being the cache directory in home.

Just do:

Code: Select all

mountpoint $CCACHE
mountpoint $TCACHE
and you will see what I mean. :evil:
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Re: autoshutdown??

Post#24 by Ed_P » 24 Mar 2016, 05:58

Bogomips wrote:Just do:

Code: Select all

mountpoint $CCACHE
mountpoint $TCACHE
and you will see what I mean. :evil:

Code: Select all

   sudo mount --bind $TCACHE $CCACHE  


guest@porteus:~$ mountpoint /home/guest/.cache/google-chrome/Default/Cache
/home/guest/.cache/google-chrome/Default/Cache is a mountpoint
guest@porteus:~$ mountpoint /tmp/google-chrome/Cache/
/tmp/google-chrome/Cache/ is not a mountpoint



guest@porteus:~$ ls -lght /tmp/google-chrome/Cache/data*
-rw------- 1 guest 264K Mar 24 01:42 /tmp/google-chrome/Cache/data_1
-rw------- 1 guest  44K Mar 24 01:42 /tmp/google-chrome/Cache/data_0
-rw------- 1 guest 1.1M Mar 24 01:42 /tmp/google-chrome/Cache/data_2
-rw------- 1 guest  13M Mar 24 01:42 /tmp/google-chrome/Cache/data_3
 :
 :

guest@porteus:~$ ls -lght /home/guest/.cache/google-chrome/Default/Cache/data*
-rw------- 1 guest 264K Mar 24 01:42 /home/guest/.cache/google-chrome/Default/Cache/data_1
-rw------- 1 guest  44K Mar 24 01:42 /home/guest/.cache/google-chrome/Default/Cache/data_0
-rw------- 1 guest 1.1M Mar 24 01:42 /home/guest/.cache/google-chrome/Default/Cache/data_2
-rw------- 1 guest  13M Mar 24 01:42 /home/guest/.cache/google-chrome/Default/Cache/data_3
 :
 :

guest@porteus:~$ 


Ed

Bogomips
Full of knowledge
Full of knowledge
Posts: 2564
Joined: 25 Jun 2014, 15:21
Distribution: 3.2.2 Cinnamon & KDE5
Location: London

Re: autoshutdown??

Post#25 by Bogomips » 24 Mar 2016, 14:48

Code: Select all

ls -light /tmp/google-chrome/Cache/data*
ls -light /home/guest/.cache/google-chrome/Default/Cache/data*
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Re: autoshutdown?? [Solved]

Post#26 by Ed_P » 24 Mar 2016, 19:21

Code: Select all

guest@porteus:~$ ls -light /tmp/google-chrome/Cache/data*
18133 -rw------- 1 guest  44K Mar 24 15:16 /tmp/google-chrome/Cache/data_0
18134 -rw------- 1 guest 264K Mar 24 15:16 /tmp/google-chrome/Cache/data_1
18136 -rw------- 1 guest 4.1M Mar 24 15:15 /tmp/google-chrome/Cache/data_3
18135 -rw------- 1 guest 1.1M Mar 24 15:15 /tmp/google-chrome/Cache/data_2
guest@porteus:~$ ls -light /home/guest/.cache/google-chrome/Default/Cache/data*
18133 -rw------- 1 guest  44K Mar 24 15:16 /home/guest/.cache/google-chrome/Default/Cache/data_0
18134 -rw------- 1 guest 264K Mar 24 15:16 /home/guest/.cache/google-chrome/Default/Cache/data_1
18136 -rw------- 1 guest 4.1M Mar 24 15:15 /home/guest/.cache/google-chrome/Default/Cache/data_3
18135 -rw------- 1 guest 1.1M Mar 24 15:15 /home/guest/.cache/google-chrome/Default/Cache/data_2
guest@porteus:~$ 
:unknown:
Ed

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Re: autoshutdown??

Post#27 by Ed_P » 26 Mar 2016, 00:54

Ed_P wrote: Is there a command that allows running a command in guest mode? Kind of a reverse sudo?
And the answer is YES. :Yahoo!:

http://forum.porteus.org/posting.php?mo ... 25&p=40870
francois wrote:To start google-chrome while you are in root mode use<;

Code: Select all

su -c /opt/google/chrome/google-chrome guest
So my chrome script now has only one prompt and looks like this:

Code: Select all

#!/bin/sh

BOOTDEV=`grep -A1 "Booting" /var/log/porteus-livedbg|tail -n1|sed 's^//^/^g'`
VERSION=$(cat /etc/porteus-version)
FOLDER=porteus${VERSION:9:3}
GUEST="$BOOTDEV/$FOLDER/Guest"
MODULES="$BOOTDEV/porteus/Modules"
MYARCH=i586
if [ `arch` = x86_64 ]; then
   MYARCH=x86_64
   MODULES="$BOOTDEV/$FOLDER/Modules"
   OPTIONAL="$BOOTDEV/$FOLDER/Optional"
fi
if [ -d $BOOTDEV/Modules ]; then
   MODULES="$BOOTDEV/Modules"
   OPTIONAL="$BOOTDEV/Optional"
fi
 
if [ `whoami` != "root" ]; then
  ktsuss "$0 $1"
# su -c "sh $0 $1"
  exit
fi

#set -x;  # Diagnostic output on!!  http://man.cx/bash

echo Press Enter when Activated
activate $OPTIONAL/zchrome.xzm >    /dev/null 2>&1 &
read


CCACHE=/home/guest/.cache/google-chrome/Default/Cache
TCACHE=/tmp/google-chrome/
#set -x;  # Diagnostic output on!!

if [ ! -d $TCACHE ]; then
   echo create /tmp
   mkdir -p $TCACHE
   [[ ! -d $CCACHE ]] && mkdir -p $CCACHE
   mount --bind $TCACHE $CCACHE  
#   ln -sf   $CCACHE   $TCACHE
fi 
#set +x;  # Diagnostic output off!!

echo Chrome - takes a moment or two
# http://forum.porteus.org/viewtopic.php?f=125&t=3874&p=43507#p40870  Thank you Francois
su -c "google-chrome-stable --disk-cache-dir=$TCACHE https://us.forgeofempires.com/page/ > /dev/null 2>&1 &" guest

echo
echo Press Enter when done using Chrome.
read
echo Deactivate
deactivate $OPTIONAL/zchrome.xzm  > /dev/null 2>&1 &
:good:

:beer:


BTW Chrome produces some bad .wh. files which show up as errors when booting with my save.dat file.

Code: Select all

find /mnt/live/memory/images/changes -name .wh.*
/mnt/live/memory/images/changes/home/guest/.config/google-chrome/Default/Extension State/.wh..wh..opq
/mnt/live/memory/images/changes/home/guest/.config/google-chrome/Default/Session Storage/.wh.000003.ldb
/mnt/live/memory/images/changes/home/guest/.config/google-chrome/Default/Session Storage/.wh.000006.ldb
/mnt/live/memory/images/changes/home/guest/.config/google-chrome/Default/Session Storage/.wh.000007.log
/mnt/live/memory/images/changes/home/guest/.config/google-chrome/Default/Session Storage/.wh.000027.ldb
/mnt/live/memory/images/changes/home/guest/.config/google-chrome/Default/Session Storage/.wh.000026.log
/mnt/live/memory/images/changes/usr/lib64/.wh.libapm.so.1
The booting errors are:

Code: Select all

cp: can't stat  'Storage/.wh.000003.ldb
 etc.
The problem is the blank in the folder names and the list appears to grow the more chrome is used.
Ed

Post Reply