Running Screen IRSSI on startup

Here is how I got Irssi to run at startup on Debian:

First if you don’t have screen installed do:

sudo apt-get install screen

Now we need to create a new file called “irssid”

So,

cd /etc/init.d/
sudo nano

Then copy and paste this into it:

#!/bin/bash

### BEGIN INIT INFO
# Provides:          irssid
# Required-Start:    $network
# Required-Stop:     $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start irssi daemon within screen session at boot time
# Description:       This init script will start an irssi session under screen using the settings provided in /etc/irssid.conf
### END INIT INFO

# Include the LSB library functions
. /lib/lsb/init-functions

# Setup static variables
configFile='/etc/irssid.conf'
daemonExec='/usr/bin/screen'
daemonArgs='-D -m -s bash'
daemonName="$(basename "$daemonExec")"
pidFile='/var/run/irssid.pid'

#
# Checks if the environment is capable of running the script (such as
# availability of programs etc).
#
# Return: 0 if the environmnt is properly setup for execution of init script, 1
#         if not all conditions have been met.
#
function checkEnvironment() {
# Verify that the necessary binaries are available for execution.
local binaries=(irssi screen)

for bin in "${binaries[@]}"; do
if ! which "$bin" > /dev/null; then
log_failure_msg "Binary '$bin' is not available. Please install \
package containing it."
exit 5
fi
done
}

#
# Checks if the configuration files are available and properly setup.
#
# Return: 0 if irssid if properly configured, 1 otherwise.
#
function checkConfig() {
# Make sure the configuration file has been created
if ! [[ -f $configFile ]]; then
log_failure_msg "Please populate the configuration file '$configFile' \
before running."
exit 6
fi

# Make sure the required options have been set
local reqOptions=(user group session)
for option in "${reqOptions[@]}"; do
if ! grep -q -e "^[[:blank:]]*$option=" "$configFile"; then
log_failure_msg "Mandatory option '$option' was not specified in \
'$configFile'"
exit 6
fi
done
}

#
# Loads the configuration file and performs any additional configuration steps.
#
function configure() {
. "$configFile"
daemonArgs="$daemonArgs -S $session irssi"
[[ -n $args ]] && daemonArgs="$daemonArgs $args"
daemonCommand="$daemonExec $daemonArgs"
}

#
# Starts the daemon.
#
# Return: LSB-compliant code.
#
function start() {
start-stop-daemon --start --quiet --oknodo --pidfile "$pidFile" \
--make-pidfile --chuid "$user:$group" --background \
--exec "$daemonExec" -- $daemonArgs
}

#
# Stops the daemon.
#
# Return: LSB-compliant code.
#
function stop() {
start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile "$pidFile" \
--chuid "$user:$group" --exec "$daemonExec" -- $daemonArgs
}

checkEnvironment
checkConfig
configure

case "$1" in
start)
log_daemon_msg "Starting daemon" "irssid"
start && log_end_msg 0 || log_end_msg $?
;;
stop)
log_daemon_msg "Stopping daemon" "irssid"
stop && log_end_msg 0 || log_end_msg $?
;;
restart)
log_daemon_msg "Restarting daemon" "irssid"
stop
start && log_end_msg 0 || log_end_msg $?
;;
force-reload)
log_daemon_msg "Restarting daemon" "irssid"
stop
start && log_end_msg 0 || log_end_msg $?
;;
status)
status_of_proc -p "$pidFile" "$daemonExec" screen && exit 0 || exit $?
;;
*)
echo "irssid (start|stop|restart|force-reload|status|help)"
;;
esac

Then save it as “irssid”

Next do

sudo chmod u+x irssid

Now do

 cd /etc/sudo nano

Then copy and paste this into it:

#
# Configuration file for irssid init script
#
# Mandatory options:
#
#    user    - Specify user for running irssi.
#    group   - Specify group for running irssi.
#    session - Specify screen session name to be used for irssi.
#
# Non-mandatory options:
#
#    args    - Pass additional arguments to irssi.
#

# Example configuration:
user='user'
group='users'
session='irssi'
args='--config /home/user/.irssi/config'

and save the file as irssid.conf

Make sure to change the ‘user’ to your user name, as well as change the path that the irssi configure file is located.

Now all there’s left is to run:

update-rc.d irssid defaults

If all things went well the irssid should not error.

Thanks to Branko Majic for his [url=http://majic.rs/book/initd-scripts/running-irssi-o4n-boot]tutorial[/url]

Advertisements

Fedora- How to change the boot order in Grub2 to Windows 7

Short version:

su -

grub2-set-default "Windows 7 (loader) (on /dev/sda1)"

grub2-mkconfig -o /boot/grub2/grub.cfg

Long version:
First check to see the menuentry for Windows 7

sudo cat /boot/grub2/grub.cfg |grep Windows

It should say something similar to:

menuentry "Windows 7 (loader) (on /dev/sda1)" --class windows --class os {

Then set Windows to default with:

sudo grub2-set-default "Windows 7 (loader) (on /dev/sda1)"

(Note, if your menuentry is different, then change the previous code to match.)
Now, you can verify that you’ve changed the default to windows with:

sudo grub2-editenv list

Now make the changes to the grub.cfg with:

sudo grub2-mkconfig -o /boot/grub2/grub.cfg

And there you go, Windows is the default OS booted at startup.

To set linux as default:

su -
cat /boot/grub2/grub.cfg |grep Fedora
grub2-set-default "Fedora Linux, with Linux 3.1.0-5.fc16.i686"
grub2-editenv list
grub2-mkconfig -o /boot/grub2/grub.cfg

As you can see, the commands are the exact same as they are for windows, except changed to target Fedora instead.

Thanks for this tip. Link