ubunix
ubunix

Reputation: 123

Making install script on linux mint

I made a program that turns on my Logitech G9 LED lights whenever I have an unread message in slack. I'm trying to made the program installable with a script but I'm unfamiliar with where things should go. Right now, the program relies on g9led and python to work. If I make an install script, where is the best place to move the executables? /usr/bin ?

My install script looks like this:

#!/bin/bash

cd /tmp
wget http://als.regnet.cz/data/g9led.c
gcc g9led.c -o g9led -lusb
rm g9led.c
mv g9led /usr/bin/g9led
mv unread_msg_monitor.py /usr/bin/unread_msg_monitor.py
sed -i ". /home/papes1ns/.virtualenvs/unread/bin/activate && python /home/papes1ns/Projects/hes_slack_integration/unread.py &" /etc/rc.local
echo "finished"
exit 0

https://github.com/papes1ns/slack_unread_msg_monitor/blob/master/unread_msg_monitor.py

Upvotes: 0

Views: 172

Answers (1)

Velimir Mlaker
Velimir Mlaker

Reputation: 10955

Nothing wrong with leaving your executables (somewhere) in your home folder.

But as far as automating your softwares, instead of /etc/rc.local, consider using an init scheme to control your services and have them start on bootup.

For example, if you have runit on your system (sudo apt-get install runit), you'd create 2 scripts, say g9monitor.runit:

#!/bin/sh
cd /home/papes1ns
exec chpst -upapes1ns:papes1ns python unread_msg_monitor.py

and g9led.runit:

#!/bin/sh
cd /home/papes1ns
exec chpst -upapes1ns:papes1ns g9led

Then copy above files to directories in /etc/sv/:

sudo mkdir -p /etc/sv/g9monitor /etc/sv/g9led
sudo cp g9monitor.runit /etc/sv/g9monitor/run
sudo cp g9led.runit /etc/sv/g9led/run

Make them executable, and create soft links in /etc/service:

sudo chmod +x /etc/sv/g9monitor/run /etc/sv/g9led/run
sudo ln -sf /etc/sv/g9monitor /etc/service/g9monitor
sudo ln -sf /etc/sv/g9led /etc/service/g9led

Once the links are made, the services should start. You can then control them via sv commands:

sudo sv status g9monitor
sudo sv down g9led
sudo sv up g9led

To disable them, remove the links:

sudo rm -f /etc/service/g9monitor
sudo rm -f /etc/service/g9led

Upvotes: 1

Related Questions