summarylogtreecommitdiffstats
path: root/emacs-openrc.install
diff options
context:
space:
mode:
authorManoel Vilela2016-11-25 21:47:46 -0300
committerManoel Vilela2016-11-25 21:47:46 -0300
commitc536b8543ec045be8d7717c057a732c08ef46524 (patch)
tree319e81d32dac045fd35efa8a85df48f9d4f9c007 /emacs-openrc.install
downloadaur-c536b8543ec045be8d7717c057a732c08ef46524.tar.gz
Add first version of emacs-openrc
Ported from gentoo using a simplified version without emacs bin wrapper. I need get some vars to put on defaults, like SHELL, HOME and USER. As the service start as root and the final user is not him, I need do some hacking here. Sorry for this shit :( BTW, in some way, this works.
Diffstat (limited to 'emacs-openrc.install')
-rw-r--r--emacs-openrc.install30
1 files changed, 30 insertions, 0 deletions
diff --git a/emacs-openrc.install b/emacs-openrc.install
new file mode 100644
index 000000000000..886b5b4b53e4
--- /dev/null
+++ b/emacs-openrc.install
@@ -0,0 +1,30 @@
+SERVICE_NAME=emacs
+SERVICE_NAME_USER=emacs.$SUDO_USER
+DEFAULT_CONF_PATH=/etc/conf.d/$SERVICE_NAME_USER
+EMACS_DAEMON_PATH=/etc/init.d/$SERVICE_NAME
+EMACS_DAEMON_USER_PATH=$EMACS_DAEMON_PATH.$SUDO_USER
+VARS_EXPORTED="SHELL\|USER\|HOME\|LANG"
+
+post_install() {
+ sudo ln -v -s -f $EMACS_DAEMON_PATH $EMACS_DAEMON_USER_PATH
+ echo ":: Installed daemon for $SUDO_USER."
+
+ echo ":: Getting useful vars from $SUDO_USER."
+ sudo -u $SUDO_USER env | grep $VARS_EXPORTED | sudo tee $DEFAULT_CONF_PATH
+ echo ":: Wrote default conf on $DEFAULT_CONF_PATH"
+
+ echo ":: Add init script on openrc."
+ sudo rc-update add $SERVICE_NAME_USER
+}
+
+post_upgrade() {
+ post_install
+ echo ":: We got a new version of emacs-openrc!"
+}
+
+post_remove() {
+ echo ":: Remove init script from openrc"
+ sudo rc-update del $SERVICE_NAME_USER
+ echo ":: Remove garbage files"
+ rm -fv $EMACS_DAEMON_USER_PATH $DEFAULT_CONF_PATH
+}