Automount script on boot up
i'm trying to get an apple script to function as a login item with auto login on a reboot.
If i log out and log into the computer the script runs fine, however on boot it fails.
I have it saved as an application with all the check boxes unchecked.
all the script does is a mount volume command.
perhaps the script needs to be saved to a specific directory? i'm running the script with auto login turned on for the admin account.
i'm trying to get an apple script to function as a
login item with auto login on a reboot.
If i log out and log into the computer the script
runs fine, however on boot it fails.
It sounded like you try to mount a server volume.
It failed because network interface isn't ready, it may not get an IP address from your DHCP server yet.
Your may need a loop to check your machine for a valid IP address. You can use Unix ifconfig command for that, see ifconfig man page for details. A simple AS script would be:
do shell script "/sbin/ifconfig en0 | /usr/bin/grep inet" -- en0 is your build-in ethernet, en1 is AirPort (I think)
You need to put it in a repeat loop and determine whether the return data contains a valid IP
Similar Messages
-
I want to run a non-ending script after boot. And I still want to be able to login. So adding the script to rc.local won't fix my problem since the boot process won't finish so that I can login.
Adding the script to "dillons" cron doesn't seem to work either since you cant specify @boot in it. And setting "* * * * *" will result in 1 minutes wait before the script runs.
Does anyone have any good ideas to solve my problem?as mentioned you can background it in rc.local, or you can create a custom /etc/rc.d file which will make it a daemon just like any other. there are templates or just copy some existing simple one. i created one for dropbox which is available on the wiki if you'd like to use it as a guide.
/edit. whoops; took too long to craft that response. ignore me.
Last edited by brisbin33 (2009-06-25 14:16:28) -
Can you run a bash script on boot in single user mode
Hey guys quick question.
Is it possible to run a bash script on boot in single user mode.
I can create a file and dump it on the root hd.
Let's call it repair.
I can then boot to single user mode and run it by typing /repair.
But I want it to do it automatically.
Every time I go into my machines that I clean for my job. I have to run sbin/fsck -fy
Then I have to mount the drive and then remove all cache files, then reboot the machines.
I would like to automate this by just holding command s and then moving to the next computer.
There must be some sort of boot daemon somewhere.
Please help.
Sincerely,
JohnHave you seen Applejack?
http://applejack.sourceforge.net/
It doesn't start automtically, but does cleanup.
Robert -
"samba-discovery". An automounter script for windows shares
Hi.
At the last lan party I found it quite annoying to mount samba shares by hand all the time (as I don't use a smb capable browser with fuse like dolphin or the like). So here's what I've come up with. Explenations on how it works are at the start of the script. You can also download it directly from here. Basically you run it and anything available on the lan will be tidily mounted to /mnt/samba-discovery/*.
#!/bin/bash
# Hi and welcome to this samba/windows share automounting script.
# It will:
# - Scan the network for windows/samba hosts.
# - Mount all their available guest shares
# - If rerun it will check if all shares are still accesible
# - Unmount everything if you use the -u option
# It will not:
# - Work on password protected shares. No idea what will happen,
# I guess mount.cifs will spit an error but the script will continue
# Run it without options to mount/rescan, use -u to unmount everything.
# Before running it please specify the options below.
# Post questions on the Archlinux forum: http://bbs.archlinux.org/viewtopic.php?pid=596979#p596979
# MOST IMPORTANTLY: If it eats all your files for breakfast, it's none
# of my responsibility! It should be quite safe though because it's
# always checking if a dir is empty before deleting it.
### Options
# Specify the name of your network adapter (e.g. eth0):
netiface='eth0'
# Specify which range of IPs you're interested in (less is faster)
lowend=1
highend=20
### Code
# Prepare samba-discovery folder
if [[ ! -d /mnt/samba-discovery/ ]]; then
mkdir /mnt/samba-discovery
fi
# Unmount all shares and clean up directories using -u
umountcount=0
uhostcount=0
if [[ $1 == "-u" ]]; then
shopt -s nullglob dotglob
dirs=(/mnt/samba-discovery/*)
(( ${#dirs[@]} )) || sharefolders=1
shopt -u nullglob dotglob
if [[ ! $sharefolders == 1 ]]; then
for i in /mnt/samba-discovery/*/*; do
umount "$i" 2>/dev/null
cd "$i" 2>/dev/null
shopt -s nullglob dotglob
files=(*)
(( ${#files[*]} )) || dirempty=1
shopt -u nullglob dotglob
if [[ ! $dirempty == 1 ]]; then
echo ">>> warning: target directory not empty although share unmounted"
echo ">>> aborting. please investigate directory:"
echo " $i"
exit 1
else
dirempty=0
rm -R "$i"
echo " share on $i unmounted, folder removed."
((umountcount++))
fi
done
for i in /mnt/samba-discovery/*; do
umount "$i" 2>/dev/null
cd "$i" 2>/dev/null
shopt -s nullglob dotglob
files=(*)
(( ${#files[*]} )) || dirempty=1
shopt -u nullglob dotglob
if [[ ! $dirempty == 1 ]]; then
echo ">>> warning: target directory not empty although all shares unmounted"
echo ">>> aborting. please investigate directory:"
echo " $i"
exit 1
else
dirempty=0
rm -R "$i"
echo " parent folder $i removed."
((uhostcount++))
fi
done
echo "-> Removed $umountcount shares and $uhostcount parent folders"
exit 0
else
echo "no parent folder found, nothing to unmount"
exit 0
fi
fi
# Normal run. Scan for shares which are no longer on the network...
if [[ ! $1 == "" ]]; then
echo "Invalid option. Aborted"
exit 1
fi
shopt -s nullglob dotglob
dirs=(/mnt/samba-discovery/*)
(( ${#dirs[@]} )) || sharefolders=1
shopt -u nullglob dotglob
if [[ ! $sharefolders == 1 ]]; then
echo ':: Cleaning up orphaned shares...'
cleancount=0
for i in /mnt/samba-discovery/*/*; do
if [[ ! $(ls $i 2>/dev/null) ]]; then
umount "$i" 2>/dev/null
cd "$i" 2>/dev/null
shopt -s nullglob dotglob
files=(*)
(( ${#files[*]} )) || dirempty=1
shopt -u nullglob dotglob
if [[ ! $dirempty == 1 ]]; then
echo ">>> warning: target directory not empty although share unmounted"
echo ">>> aborting. please investigate directory:"
echo " $i"
exit 1
else
dirempty=0
rm -R "$i"
echo " share on $i no longer accesible, removed."
((cleancount++))
fi
else
if [[ ! $(cat /proc/mounts | grep "cifs" | awk '{print $2}' | grep $i) ]]; then
cd "$i" 2>/dev/null
shopt -s nullglob dotglob
files=(*)
(( ${#files[*]} )) || dirempty=1
shopt -u nullglob dotglob
if [[ ! $dirempty == 1 ]]; then
echo ">>> warning: target directory not empty although nothing mounted there"
echo ">>> aborting. please investigate directory:"
echo " $i"
exit 1
else
dirempty=0
rm -R "$i"
echo " nothing mounted on $i, removed."
((cleancount++))
fi
fi
fi
done
echo "-> Cleaned out $cleancount shares"
fi
# ... and then scan for new hosts and mount shares
echo ':: Scanning for new hosts and shares...'
netaddr=$(ifconfig eth0 | grep "inet addr" | awk '{print $2}' | awk -F ":" '{print $2}' | awk -F "." '{print $1"."$2"."$3}')
hostcount=0
sharecount=0
for ((ip=$lowend; ip<=$highend; ip++)); do
printf " scanning $netaddr.$ip...\r"
if (( $(nmap -PN -p139,445 "$netaddr.$ip" | grep -e "139/tcp open" -e "445/tcp open" | wc -l) == 2 )); then
hostwinname="$( nmblookup -A $netaddr.$ip | grep "<00>" | grep -v "<GROUP>" | awk '{print $1}')"
hostdirname="$(echo $hostwinname | tr [:upper:] [:lower:])"
echo " found $hostwinname on $netaddr.$ip"
IFS=$'\n' shares=($(smbclient -N -gL \\\\$netaddr.$ip\\ 2>&1 | grep -e "Disk|" | grep -v '\$' | awk -F "|" '{print $2}'))
for share in ${shares[*]}; do
sharedir="$(echo $share | sed s/\ /_/g | tr [:upper:] [:lower:])"
if [[ "$(cat /proc/mounts | grep ",unc=\\\\\\\\$netaddr.$ip\\\\$share,")" ]]; then
echo " share "$share" already mounted in /mnt/samba-discovery/$hostdirname/$sharedir"
else
if [[ ! -d "/mnt/samba-discovery/$hostdirname" ]]; then
mkdir "/mnt/samba-discovery/$hostdirname"
#echo "$hostwinname:$hostdirname:$netaddr.$ip" >> /mnt/samba-discovery/$hostdirname/ip.txt
fi
if [[ ! -d "/mnt/samba-discovery/$hostdirname/$sharedir" ]]; then
mkdir "/mnt/samba-discovery/$hostdirname/$sharedir"
else
cd "/mnt/samba-discovery/$hostdirname/$sharedir"
shopt -s nullglob dotglob
files=(*)
(( ${#files[*]} )) || dirempty=1
shopt -u nullglob dotglob
if [[ ! $dirempty == 1 ]]; then
echo ">>> warning: mounting directory not empty although share not mounted!"
echo ">>> aborting. please investigate directory:"
echo " /mnt/samba-discovery/$hostdirname/$sharedir"
exit 1
fi
dirempty=0
fi
mount "//192.168.1.$ip/$share" "/mnt/samba-discovery/$hostdirname/$sharedir" -o guest 2>/dev/null
echo " mounted "$share" in /mnt/samba-discovery/$hostdirname/$sharedir"
((sharecount++))
fi
done
((hostcount++))
fi
done
echo "-> Mounted $sharecount shares from $hostcount hosts."
# Remove samba-discovery folder if it is empty
if [[ -d /mnt/samba-discovery/ ]]; then
cd "/mnt/samba-discovery/"
shopt -s nullglob dotglob
files=(*)
(( ${#files[*]} )) || sambadirempty=1
shopt -u nullglob dotglob
if [[ sambadirempty == 1 ]]; then
rm -R /mnt/samba-discovery/
fi
fi
Here's some sample output of how it will look, including one orphaned share and a new one on a rerun of the script:
[root@Mothership samba-discovery]# /home/medja/scripts/samba-discovery
:: Cleaning up orphaned shares...
share on /mnt/samba-discovery/blackrabbit/conflict_denied_ops no longer accesible, removed.
-> Cleaned out 1 shares
:: Scanning for new hosts and shares...
found BLACKRABBIT on 192.168.1.2
share CD-Images already mounted in /mnt/samba-discovery/blackrabbit/cd-images
share CD-Images2 already mounted in /mnt/samba-discovery/blackrabbit/cd-images2
share Filme already mounted in /mnt/samba-discovery/blackrabbit/filme
share Filme2 already mounted in /mnt/samba-discovery/blackrabbit/filme2
mounted Music Library in /mnt/samba-discovery/blackrabbit/music_library
found MOTHERSHIP on 192.168.1.4
share space already mounted in /mnt/samba-discovery/mothership/space
found EEE on 192.168.1.5
share SharedDocs already mounted in /mnt/samba-discovery/eee/shareddocs
-> Mounted 1 shares from 3 hosts.
Last edited by Shapeshifter (2009-08-07 18:51:05)thanks a lot, i wanted to write that script for a long time, but never got around. one thing though, you shouldn't mount stuff in a subfolder of /mnt because /mnt itself should be kept for such purposes (unix file hierarchy standards, afaik)
but that should be easily fixed by myself
cheers
Phil
Last edited by Heller_Barde (2009-08-07 21:42:46) -
How to start radeon script during boot?
My system hangs during startx. I have got input what to do but now, I need to create my own systemd.service file to start the script during boot. I have made following /etc/rc.local:
modprobe -r radeon
modprobe -r drm
modprobe radeon modeset=1
and get 644 permissions.
To start this service have I tried /etc/systemd/system/rc-local.service
[Unit]
Description=/etc/rc.local
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/etc/rc.local
[Install]
WantedBy=multi-user.target
and systemctl enable rc-local.service
When I boot the system I get the error:
Failed to start /etc/rc.local
Any suggestion will be appreciated.I think it would be better to launch startx manually and look at the output! I also have a radeon card and use the oss driver. Nothing has to be done for it to work. Are you sure you haven't messed up something else? Something weird in your grub config? What about your files in /etx/X11/xorg.conf.d? Remove every "improvement" you tried to do, I'm pretty sure startx will work just fine then.
-
Hello,
I'm trying to make a simple script to execute at the boot time, which call a program ( C ), but I cant do it. I don't know if there is some special "template" to make that script (like Freebsd has). If you could give some help, I'm new at Solaris (by the way, using Sol 10, and Sol 11 Express).
thanks,
Miguel GarciaThat should be all, any script named S-something and which is placed in /etc/rc2.d or /etc/rc3.d will be executed at boot by the /sbin/rc2 and /sbin/rc3 scripts.
It will be called with the argument "start".
If its not working, test the script standalone (i.e. /etc/rc3.d/Sdiverse start) and see what it returns.
Also, the $PATH and $LD_LIBRARY_PATH might contain unexpected (i.e. minimum) values. Typically $PATH is set to /usr/bin and /usr/sbin and $LD_LIBRARY_PATH will only contain /lib and /usr/lib .
The working directory is probably / .
For rc3.d scripts, also check the logfile:
/var/svc/log/milestone-multi-user-server:default.log
.7/M. -
[SOLVED] How do I start scripts at boot up?
I've been looking around for awhile and can't find a way to auto-start scripts I've written in the console (the only ways I've found are for older systems using /etc/rc.local, but my system doesn't have this file. The only things I've found for systemd are about starting daemons. I'm not running a desktop environment on this system nor do I plan to (I'm using this machine as a server), so I can't put the scripts in a directory that auto-starts them like I can in KDE (and even then, I think that's only auto-starting them after login; I need these scripts to run without need of logging in). And since my scripts aren't services I can't use "systemctl enable" to make them start at bootup.
Does anyone know how to start scripts when the system boots?
Last edited by Zukaro (2013-01-10 23:02:22)https://wiki.archlinux.org/index.php/Sy … process.3F
-
Systemd improperly automounting drives on boot
systemd is automounting my Windows partitions (/dev/sda2 and /dev/sda3) on boot. Furthermore, something is going wrong in the mount process. Attempting to access /media or either of the two mount directories results in the error "Transport endpoints are not connected." I've read through the docs and I can't find a way to stop the drives from being mounted.
The drives are not in my fstab, I have disabled volume management in thunar, and completely removed thunar-volman. To the best of my knowledge, there are no other programs on my system that would automount drives.
Last edited by soupcan (2012-10-19 05:51:52)I'm sorry that I haven't provided you with enough information. Unfortunately, I've given you everything I know about the problem. Having been an Arch user for more than 4 years, I went through the resources provided to me - man, then wiki, then a forum search, then google. Now I've made a post explaining the issue to the best of my knowledge. I have little to no idea of how systemd works, I have no experience in configuring it, and I'm not seeing any errors in my logs. So, being unable to fix the problem myself, I made this post. Perhaps, instead of berating me about the supposed quality of my post, you tell me what information you or others might need to help me with my issue?
-
Use Launchd to run shell script at boot
Hello
I'm trying to create a plist file that will run a shell script at bootup of the server.
I have the following xml so far in the plist file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>com.apple.mymount</string>
<key>ProgramArguments</key>
<array>
<string>/mount-script/./mount.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
The shell script is just a mount command:
#!bin/sh
#MOUNT folder X ON server Y
sudo -u _www mount_smbfs -f 777 -d 777 //username:password@server/folder /mnt/mount
The shell script works fine from the terminal.
I can see the plist has loaded after bootup but the script doesn't run.
What am I doing wrong?
Would need some help please!First problem:
<string>com.apple.mymount</string>
com.apple is (or at least should be) reserved for Apple scripts, not your own. This should be renamed to your own domain (or your own name if you don't have a domain).
In addition the .plist file name should match (so if you rename the script Label to be 'com.my.mount' then the .plist should be com.my.mount.plist. You don't include the file name in your post to know if you're already doing that.
Second:
<string>/mount-script/./mount.sh</string>
What? That looks wrong to me. Of course, it could be right, but the '/./ in the middle worries me, so I just can't think it is.
Where is the script, really?
Third:
sudo -u _www mount_smbfs -f 777 -d 777 //username:password@server/folder /mnt/mount
No. Never use 'sudo' within a launchd task. If you need the task to run as a different user then use the launchd keyword UserName to specify that username:
<key>UserName</key>
<string>_www</string>
I can see the plist has loaded after bootup but the script doesn't run.
If none of the above fixes it then look at the logs and tell us what it has to say. /var/log/system.log -
Run shell script as root on boot
Hi!
I have the need to run a shell script on boot up as root.
It will not run as any other user because the software that the shell script runs requires root permissions, and I don't use my computer as root. I can't run it at login and use sudo because it would ask for a password and hang.
How can I have the shell script auto-run at boot (or login) as root?
Thanks
RossHi,
first of all you can store your shell script anywhere on your system, I prefere the location /usr/local/scripts (this doesn't exist by default).
Second you have to create a LaunchDeamon script in /Library/LaunchDeamons which execute your shell script at boot as root.
An example:
-------------------------snip------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST
1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>YOURIDENTIFIERNAME</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/scripts/YOUR_SCRIPT.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>ROOT</string>
<key>GroupName</key>
<string>WHEEL</string>
</dict>
</plist>
-------------------------snap------------------------
http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPSystemS tartup/Articles/LaunchOnDemandDaemons.html
To run a script as root during a user login you can configure a LoginHook. To create a LoginHook login as the relating user and type the following commad:
sudo defaults write com.apple.loginwindow LoginHook /Path/To/Your/Script
http://support.apple.com/kb/HT2420
Hope that helps
Bye Tom -
When I turn on my computer, and click on an user, I get the passoword automatically filled in with 50 characters that I have to delete, before entering the correct password.
This is a result of my son trying to find a hack into my admin password (to get into his managed account), and loading some type of script that boots at startup. Unfortunately, he has not been able to explain to me what it is he did.
How can i detect what the problem is and disable it.Without knowing exactly what he did it would be hard to say. I would log in and try changing the password first, then open up system preferences > accounts > Log in items and see if you see anything running there that should not be.
-
Startup script to load shortcuts - in a Citrix environment
Let me offer a sample of what I have and ask if anyone knows how to fill in the gaps.
For starters, a listening script upon booting up InDesign:
#target InDesign
#targetengine session
//collect the name of current user
var userName = getUser();
function getUser() {
var myUser = ($.os.substring(0, 7)=="Windows")
? $.getenv("USERNAME")
: $.getenv("USER");
return myUser;
// var startupScriptsFolder = "/z/Scripting/Startup scripts/";
var startupScriptsFolder = "/Applications/Adobe InDesign CC/Scripts/startup scripts/";
var startupScriptFiles = Folder(startupScriptsFolder).getFiles();
for (var i = 0; i < startupScriptFiles.length; i++) {
app.doScript(startupScriptFiles[i]);
then the script itself:
#target InDesign
#targetengine session
//get or create folder for script preferences
var scriptPrefsFolderPath = "/Users/madmac55/Library/Preferences/Adobe InDesign/Version 9.0/en_US/InDesign Shortcut Sets/";
if (Folder(scriptPrefsFolderPath).exists == false) {
Folder(scriptPrefsFolderPath).create();
var locationPrefsFilePath = scriptPrefsFolderPath + "/ MyShortcuts.indk";
This hasn't worked for me and it's a hacked solution at best. So I am wondering how to get it all to click. In a Citrix environment (windows), Adobe puts the preferences in a hidden folder path ~/AppData/Roaming/ and this is where it's tough to find them — on the server(s) you land on.
Because you land on an arbitrary server, you have to run the getUser statement first, then drill down inside. I realize I have mixed paths of Mac & PC, and I'm really writing abiout a PC environment, but paths are interchangeable. It's the script that counts.Hey Mac,
I'm not sure if this will work for you as I've only used it when making .bat files... but, in Windows, you can reference the folder directly by using the variable "%USERNAME%"
C:\Users\%USERNAME%\AppData\Roaming\Adobe\InDesign\Version 5.0\Scripts\Scripts Panel\
Hope it helps. -
OSD: How to run script(it's In package) without download
I has a hta script need to run before "Partition Disk", but this script is in a package, if I want to run it, it need to download to harddisk. so it will fail, because no partition.
So how to run directly this script in network, without download to C drive.
PS: I think I can put this script into boot image, but it is not easy to maintain. So I want to run directly in network
06/30:
Thank you for everyone support!
My Hta will warn users that the following operations will format data.So "Create a temporary partition on the disk"--It is not for my requirement.
As Narcoticoo mentioned, I want to use "Package Share Settings" to share folder, so how to map this folder with automatically recognize
DP?
just like \\%DP%\htaThank you for everyone support!
As Narcoticoo mentioned, I want to use "Package Share Settings" to share folder, so how to map
this folder with automatically recognize DP?
just like \\%DP%\hta
Is there this variable? -
[solved]Trying to insert a blocking systemd unit into the boot process
What i'm trying to do is to start (and *wait* for it to complete) a unit before starting another.
In particular, i need to create and mount a partition on the fly before any filesystem gets mounted.
My unit file is:
# cat /etc/systemd/system/early-boot-koko.service
[Unit]
Description=Configurazione ottimale per il boot da rete
[Service]
Before=systemd-remount-fs.service
#Nice=19
#IOSchedulingClass=3
#IOSchedulingPriority=7
Type=oneshot # is forking instead of oneshot needed here?
ExecStart=/root/scripts/early-boot.sh
TimeoutSec=0
#StandardInput=tty
RemainAfterExit=yes
I created even created an override to systemd-remount-fs.service and added early-boot-koko.service to the "After" array:
]# cat /etc/systemd/system/systemd-remount-fs.service
# This file is part of systemd.
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Remount Root and Kernel File Systems
Documentation=man:systemd-remount-fs.service(8)
Documentation=http://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
DefaultDependencies=no
Conflicts=shutdown.target
After=systemd-readahead-collect.service systemd-readahead-replay.service systemd-fsck-root.service early-boot-koko.service
Before=local-fs-pre.target local-fs.target shutdown.target
Wants=local-fs-pre.target
ConditionPathExists=/etc/fstab
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/systemd/systemd-remount-fs
But when i boot, i notice that early-boot-koko.service is still running while systemd-remount-fs has exited :
# systemctl |grep 'early\|remount'
early-boot-koko.service loaded active running Configurazione ottimale per il boot da rete
systemd-remount-fs.service loaded active exited Remount Root and Kernel File Systems
...but i need early-boot-koko.service to complete before systemd-remount-fs is started.
What am i doing wrong?
Thanks.
Last edited by kokoko3k (2014-10-09 12:14:23)...it was the comment on the same line:
Type=oneshot # is forking instead of oneshot needed here?
solved... -
Run script before loggin starts
Hi everyone
I'm using a tmpfs for my /var/log folder, and because I don't want to loose all logs I have modified /etc/rc.local.shutdown following this thread so everything gets backed up each time in a different folder named after the time at which I shutdown.
https://bbs.archlinux.org/viewtopic.php … 10#p528010
But I'd prefer to have a XYZ folder with all logs which gets loaded to my tmpfs /var/log, so everything works like normal, and finally before shutdown, everything is copied back to folder XYZ. This way my HDD is only accessed for loggin matters at startup and shutdown. So far it's not difficult, except I want to run my script which does just that, before any loggin starts.
How can I execute commands or run a script while booting just between my tmpfs is mounted (declraed in /etc/inittab) and loggin starts? If possible including the minilogger at arch boot
Thanks very much in advance
Last edited by agon (2011-02-24 22:07:02)Here we are again
I'm trying it now the way you suggest. I've written two simple scripts (my first ones ) which do as following:
[ LOGs => RAM ]
I call to this script in /etc/rc.local. It saves all logs in ram and then links the so that they appear again in /var/log
note: my /tmp folder is a tmpfs
#!/bin/bash
#/usr/bin/log-ram.sh
# Create /tmp/log: necessary for each boot because /tmp is volatile
# Copy /var/log to tmp/log: copy my complete logs to ram
# Rename /var/log to /var/log.backup: so I have a backup of them
# Create a new empty /var/log
#Link /var/log to /tmp/log: all logs (located in ram) appear in /var/log
echo "Copiando LOGs de HDD a RAM"
mkdir /tmp/log
cp -Rp /var/log/* /tmp/log/
mv /var/log /var/log.backup
mkdir /var/log
ln -sf /tmp/log/* /var/log/
Questions:
-Do you recommend calling this script latter or is it here ok (/etc/rc.local)? If it would be latter, where do you reccomend it? As you already noted, it has to be excecuted as root
[ LOGs => HDD ]home sweet home)
I call this script in /etc/rc.local.shutdown
All logs get copied back to /var/log and also a backup is made. Note that each time this script is ececuted a new backup is generated. That menas that for now I have to manually erase them when they get to many. Later (when I learn a bit more of scripting) I'll make the oldest get automatically erased.
#!/bin/bash
#/usr/bin/log-unram.sh
#Refresh the content of /var/backup so it's up to date
#Remove /var/log: so all symbolic links get erased
#Recreate /var/log: is there a faster way to do this and the last step?
#Copy from /tmp to /var: from RAM to HDD
#Rename and change directory of /var/log.backup with an unique identifier (time at which script is run).
echo "Copiando LOGs de RAM a HDD"
now=`date +"%Y%m%d_%Hh%M"`
cp -Rp /tmp/log/* /var/log.backup/
rm -r /var/log
mkdir /var/log
mv /tmp/log /var/log
mv /var/log.backup /var/log.old/$now/
Questions:
Is there a faster way to erase al symbolic links
As said, this are my two first attempts to writte a bash script (excetp the hello world one lol). So I probably did a lot wrong.
For now it seems to work (when calling them from shell) but I still didnt tried them with real powerup & shutdown. (Ill do it after posting this).
Thanks in advance
EDIT:
These scripts are give me problems. I'm trying to make now a syngle script which copies from HDD -> RAM or RAM -> HDD depending on if logs are already loaded or not. This way If my system crashes I dont have problems while booting (like the firefox-sync script).
As soon as I have something, I'll post it here
Last edited by agon (2011-02-27 13:06:11)
Maybe you are looking for
-
IPhone 6: Data not working on T-Mobile?
I recently switched from Verizon to T-Mobile's Simple Choice family plan with unlimited talk, text, and unlimited 2G data (with an additional 2.5G 4G data/month until 2016, it will drop to 1G 4G/month). I have full text and call functionality (sendin
-
I think what I'm asking is clear without needing more details.
-
Browsers not opening like they were closed
After awaking from sleep sometimes when I click on my browsers they open at a reduced size. Not the same size as when I closed them.
-
Inserting Comments into Universe SELECT and WHERE clauses
I am converting an application from Crystal Reports to Business Objects. In conjunction with that, I am (manually) converting our Business View to a Universe. In Crystal we frequently documented our formulas using the Crystal Syntax "//...". Out o
-
My new ( one week old) Ipodtouch has numerous scratches on the back side . It has never been in my pocket , I do not wear rings , it lives on my desk in its plastic case. Could they have sold me a refurbished device as new ? I would like to know . I