Skip to content

replabrobin/sd2runit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

This repository contains scripts which I use to convert an Arch Linux
system with systemd init to an Arch Linux system that uses runit.

After obtaining the scripts put them into a directory. I do this fairly early
and use /root/sd2runit as the location to keep the scripts.

After this there are two approaches to the conversion:

1) foolhardy expert:
    # cd /root/sd2runit
    # ./runit-go
    # ./force-shutdown

2) cautious:
    # cd /root/sd2runit
    # bash  # get a new shell
    # ./funcs   #put the functions into the current shell
    # now cut and paste each set of commands from the
    # runit-go script into your terminal; then
    # ./force-shutdown
    # I put the script below for your convenience

    ########################runit-go start
    #!/bin/bash
    HERE=$(
        HERE=$(dirname $0)
        [ -n "$HERE" ] && cd "$HERE"
        pwd
        )
    . $HERE/funcs
    #make a package list
    [ ! -f "$HERE/old-pkgs.lst" ] && installed_packages >"$HERE/old-pkgs.lst"
    #save /etc/systemd
    [ ! -f "$HERE/etc_systemd.tar.bz2" ] && (cd /etc && tar cjf "$HERE/etc_systemd.tar.bz2" systemd)
    tmp="$HOME/tmp"
    [ ! -d $tmp ] && mkdir $tmp && chmod og-rwx $tmp
    HOSTNAME="$(cat /proc/sys/kernel/hostname)"
    LTZ="$(readlink /etc/localtime)"
    LTZ="${LTZ#/usr/share/zoneinfo/}"
    KEYBOARD="$(localectl status | sed -n -e'/VC Keymap:/{s/^.*:\s*//;s/\s*$//;p}')"

    # update and get basic stuff
    pacman -Syu --noconfirm
    pacman -S --needed makepkg base-devel git jshon expac sudo --needed --noconfirm

    #get an aur installer
    ([ ! -x ~/tmp/packer/packer ] && cd ~/tmp && hg clone https://bitbucket.org/replabrobin/packer)

    #build the util-linux-nosystemd stuff
    #util-linux contains su so maybe we need to build first
    #and then install separately
    packer -S util-linux-nosystemd \
        --build-only --noedit --skippgpcheck --noconfirm \
        --makepkg-log ${tmp}/util-linux-nosystemd.makepkg.log

    # as it says
    remove_systemd

    #and these
    pkg_remove --noconfirm --nodeps udev dbus procps-ng \
        syslog-ng mkinitcpio polkit upower udisks2 \
        util-linux libutil-linux

    #must be done specially to avoid su problems
    packer -S util-linux-nosystemd --install-only --noconfirm --nodeps --force \
        --aurpkg 'util-linux-nosystemd-[0-9]*' \
        --aurpkg 'libutil-linux-nosystemd-[0-9]*'

    #now our desired replacements
    for pkg in \
        arch-runit \
        arch-runit-services \
        eudev \
        eudev-systemdcompat \
        dbus-nosystemd \
        procps-ng-nosystemd \
        syslog-ng-nosystemd \
        mkinitcpio-nosystemd \
        socklog \
        polkit-consolekit \
        consolekit \
        upower-pm-utils \
        udisks2-nosystemd \
        ;do
        packer -S ${pkg} --skippgpcheck --noconfirm --noedit --makepkg-log ${tmp}/${pkg}.makepkg.log
    done

    #rebuild the initramfs
    mkinitcpio -p linux

    if is_package_installed "xorg-server" ; then
        #avoid bringing in xorg-server
        for pkg in \
            xorg-xwrapper \
            desktop-privileges \
            ;do
            packer -S ${pkg} --noconfirm --noedit --makepkg-log ${tmp}/${pkg}.makepkg.log
        done
    fi

    #set up our rc.conf
    if [ -r /etc/rc.conf ]; then
        sed -i -e'/^#HOSTNAME=/s/^.*$/HOSTNAME='"$HOSTNAME"'/
    /^#TIMEZONE=/s[^.*$[TIMEZONE='"$LTZ"'[
    /^#KEYMAP=/s[^.*$[KEYMAP='"${KEYBOARD}"'[
    /^#FONT=/s[^.*$[FONT=lat9w-16[' /etc/rc.conf
    else
        (
        echo "HOSTNAME='$HOSTNAME'"
        echo "HARDWARECLOCK='UTC'"
        echo "TIMEZONE='${LTZ}'"
        echo "KEYMAP='${KEYBOARD}'"
        echo "FONT='lat9w-16'"
        ) > /etc/rc.conf
    fi

    #for thos like me that may have oblogout installed
    if [ -r /etc/oblogout.conf ]; then
        sed -i -e'/^\s*[commands]/,${
    /^shutdown\s*=/s[^.*$[shutdown = /home/robin/bin/robin-sleep poweroff[
    /^restart\s*=/s[^.*$[restart = /home/robin/bin/robin-sleep reboot[
    /^hibernate\s*=/s[^.*$[hibernate = /home/robin/bin/robin-sleep hibernate[
    /^suspend\s*=/s[^.*$[suspend = /home/robin/bin/robin-sleep suspend[
    }
    /^\s*buttons\s*=/s[^.*$[buttons = cancel, logout, suspend, hibernate, restart, shutdown, lock[' /etc/oblogout.conf
    fi

    #ensure we have a log user and group
    if ! id -g log 2>/dev/null; then
        groupadd -g 19 log
    fi
    if ! id -u log 2>/dev/null; then
        useradd -M -g log -l -s /usr/bin/nologin -c 'socklog user' -r -u 19 log
    fi

    #link in some useful things
    for x in unix klog; do 
        [ ! -d "/etc/sv/socklog-$x" ] && socklog-conf $x nobody log
        ln -s ../../../sv/socklog-$x /etc/runit/runsvdir/current
    done
    installed_packages >"$HERE/new-pkgs.lst"
    ########################runit-go end

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages