[Lunar-commits] <moonbase> openafs: Added systemd services. Query user for default cell and cache size.
Stefan Wold
ratler at lunar-linux.org
Sat Jun 30 18:30:10 CEST 2012
commit d6c24341f397819ac7be9a2fbb92c96abcea5282
Author: Stefan Wold <ratler at lunar-linux.org>
Date: Sat Jun 30 18:30:10 2012 +0200
openafs: Added systemd services. Query user for default cell and cache size.
---
filesys/openafs/BUILD | 23 ++++++++++++++--------
filesys/openafs/CONFIGURE | 18 +++++++++++++++++
filesys/openafs/POST_INSTALL | 6 ------
filesys/openafs/systemd.d/openafs-client.service | 17 ++++++++++++++++
filesys/openafs/systemd.d/openafs-server.service | 10 ++++++++++
5 files changed, 60 insertions(+), 14 deletions(-)
diff --git a/filesys/openafs/BUILD b/filesys/openafs/BUILD
index f8fd107..51e0786 100644
--- a/filesys/openafs/BUILD
+++ b/filesys/openafs/BUILD
@@ -77,21 +77,28 @@
install -p -m 755 $SOURCE_CACHE/$SOURCE3 /usr/sbin/killafs &&
touch /etc/openafs/SuidCells &&
- # Default to openafs.org cell
+ # Default to openafs.org unless custom cell has been chosen
if [ ! -f /etc/openafs/ThisCell ]; then
- echo "openafs.org" > /etc/openafs/ThisCell
+ echo "${AFSCELL:-openafs.org}" > /etc/openafs/ThisCell &&
+ touch /etc/openafs/ThisCell
fi &&
# Create cacheinfo file, 200Mb size
if [ ! -f /etc/openafs/cacheinfo ]; then
- echo "/afs:/var/cache/openafs:200000" > /etc/openafs/cacheinfo
- fi
+ # Convert to bytes from Mb
+ AFSCACHESIZE=${AFSCACHESIZE:-200}
+ AFSCACHESIZE=$((AFSCACHESIZE * 1000))
+ echo "/afs:/var/cache/openafs:$AFSCACHESIZE" > /etc/openafs/cacheinfo &&
+ touch /etc/openafs/cacheinfo
+ fi &&
- # Copy conf and rc files
- sedit "s;^OPTIONS=.*;OPTIONS=\"-nosettime -fakestat\";" $SOURCE_DIRECTORY/src/afsd/afs.conf.linux &&
- if [ ! -f /etc/config.d/afs ]; then
+ # Copy conf and rc files (only needed by sysvinit systems)
+ if module_installed sysvinit; then
+ sedit "s;^OPTIONS=.*;OPTIONS=\"-nosettime -fakestat\";" $SOURCE_DIRECTORY/src/afsd/afs.conf.linux &&
+ if [ ! -f /etc/config.d/afs ]; then
install -p -m 644 $SOURCE_DIRECTORY/src/afsd/afs.conf.linux /etc/config.d/afs
- fi &&
+ fi
+ fi &&
# Ugly but we need a new cellservdb everytime we run lin
rm -f $SOURCE_CACHE/$SOURCE2
diff --git a/filesys/openafs/CONFIGURE b/filesys/openafs/CONFIGURE
new file mode 100644
index 0000000..96c90bb
--- /dev/null
+++ b/filesys/openafs/CONFIGURE
@@ -0,0 +1,18 @@
+# Only trigger questions on lin -r
+if [ -n "$RECONFIGURE" ]; then
+ if query "Do you want to change AFS cell (currently: ${AFSCELL:-openafs.org})?" n; then
+ RESULT=$(dialog --title "Change OpenAFS default cell" \
+ --stdout \
+ --inputbox "AFS cell name:" 0 0)
+ if [ -n "$RESULT" ]; then
+ set_module_config AFSCELL $RESULT
+ fi
+ fi
+
+ if query "Do you want to change default AFS cache size (currently: ${AFSCACHESIZE:-200} Mb)?" n; then
+ RESULT=$(dialog --title "Change OpenAFS default cache size" \
+ --stdout \
+ --inputbox "AFS cache size in Mb:" 0 0)
+ set_module_config AFSCACHESIZE ${RESULT:-200}
+ fi
+fi
diff --git a/filesys/openafs/POST_INSTALL b/filesys/openafs/POST_INSTALL
deleted file mode 100644
index 3854f08..0000000
--- a/filesys/openafs/POST_INSTALL
+++ /dev/null
@@ -1,6 +0,0 @@
-message "" &&
-message "Before starting AFS remember to add your AFS cell" &&
-message "to /etc/openafs/ThisCell. You might also want to" &&
-message "change the cache size which is by default 200Mb" &&
-message "in /etc/openafs/cacheinfo." &&
-message ""
diff --git a/filesys/openafs/systemd.d/openafs-client.service b/filesys/openafs/systemd.d/openafs-client.service
new file mode 100644
index 0000000..9e37b07
--- /dev/null
+++ b/filesys/openafs/systemd.d/openafs-client.service
@@ -0,0 +1,17 @@
+[Unit]
+Description=OpenAFS Client Service
+After=syslog.target network.target
+
+[Service]
+Type=forking
+ExecStartPre=/sbin/modprobe libafs
+ExecStart=/usr/sbin/afsd -dynroot -fakestat -afsdb
+ExecStop=/usr/sbin/killafs TERM
+ExecStop=/usr/sbin/killafs KILL
+ExecStop=/bin/umount /afs
+ExecStop=/usr/sbin/afsd -shutdown
+ExecStop=/sbin/rmmod libafs
+KillMode=none
+
+[Install]
+WantedBy=multi-user.target remote-fs.target
diff --git a/filesys/openafs/systemd.d/openafs-server.service b/filesys/openafs/systemd.d/openafs-server.service
new file mode 100644
index 0000000..75764d6
--- /dev/null
+++ b/filesys/openafs/systemd.d/openafs-server.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=OpenAFS Server Service
+After=syslog.target network.target
+
+[Service]
+ExecStart=/usr/sbin/bosserver
+ExecStop=/usr/bin/bos shutdown localhost -wait -localauth
+
+[Install]
+WantedBy=multi-user.target
More information about the Lunar-commits
mailing list