Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Little script help please
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
rjhsynios
n00b
n00b


Joined: 31 Mar 2010
Posts: 3

PostPosted: Wed Mar 31, 2010 11:20 am    Post subject: Little script help please Reply with quote

Hi,
I need a script so that on shutdown my encrypted file system will be umounted and call cryptsetup luksClose.
I guess the right place is in /etc/init.d/ and to use the stop() { } to place the commands and then to rc-update add the script, however how to do I specify the script to be run early in the shutdown sequence and is it possible for the script to check if the mount point is mounted before it executes the commands. Any help would be appreciated, I am not much of a scripter.

Thanks.
Back to top
View user's profile Send private message
ursusca
Apprentice
Apprentice


Joined: 10 Sep 2008
Posts: 284
Location: Toronto ON, CANADA

PostPosted: Wed Mar 31, 2010 6:53 pm    Post subject: Reply with quote

Hello,
You may unmount and shut off the encrypted partition manually like this:
Code:
# umount crypted
# cryptsetup luksClose <encrypted_partition>


So my sugestion is to try this:

Code:
#! /bin/bash
# /etc/init.d/my_script
#

touch /var/lock/my_script

# Carry out specific functions when asked to by the system
case "$1" in
  start)
    echo "Starting my_script"
    echo "I will create the encrypted partition later"
    ;;
  stop)
    echo "Stopping my script"
    umount crypted
    cryptsetup luksClose <encrypted_partition>
    ;;
  *)
    echo "Usage: /etc/init.d/my_script {start|stop}"
    exit 1
    ;;
esac

exit 0

_________________
You deserve free software!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum