Permalink
Browse files

Needed to build .xzm modules

  • Loading branch information...
1 parent 39c6a3d commit 31cedc661db4a55c514beafe8759a2bb730e181c @Sitwon Sitwon committed Jul 1, 2012
View
@@ -0,0 +1,114 @@
+#!/bin/bash
+# Script by Brokenman
+# Script to activate modules in the folder of your choice and sub folders.
+# You can prepend all your OFFICE apps with 'office' (e.g office-gcalc.xzm)
+# and activate them with <script> <office>
+# or you can put all your office apps in a folder called 'office'
+# and they will all be activated with <script> <office>
+
+if [ `whoami` != "root" ]; then
+ echo "Please enter root's password below"
+ mod=`readlink -f $1`
+ su - -c "/opt/porteus-scripts/act.sh $mod"
+ exit
+fi
+
+script=${0##*/}
+USER=`whoami`
+CONFPATH="/etc/modtools"
+CONFIG="$CONFPATH/modtoolsrc"
+
+
+usage()
+{
+cat <<EOF
+
+##################
+USAGE:
+$script <module>
+$script <folder>
+##################
+
+Just open a terminal and enter the above commands. This
+script works independently of any other porteusscripts script.
+
+If the module exists in your chosen module directory then
+module will be activated.
+
+If the folder exists in your optional dir then all modules
+within folder will be activated.
+
+The script uses a wildcard.
+$script bluetoo = $script bluetooth
+
+In this case any folder called bluetooth will have modules
+inside activated, or modules called bluetooth.xzm found
+anywhere within the optional folder (or sub folders) will
+be activated.
+
+To see this help ... enter $script with nothing following.
+##################
+
+EOF
+exit
+}
+
+modpath()
+{
+echo
+echo "*****************************************************************************"
+echo "Please type in the path to your Porteus optional module folder and press enter. "
+echo "This is the folder that you keep all of your modules in. You will only need to "
+echo "enter this path once and a configuration file will be saved."
+echo
+read MODFOLDER
+
+if [ ! -d "$MODFOLDER" ]; then
+ echo
+ echo "You must select a module folder to continue. "
+ echo "You will only have to enter this path once"
+ exit
+ else
+ mkdir -p $CONFPATH
+ touch $CONFIG
+ echo "[modfolder]" > $CONFIG
+ echo $MODFOLDER >> $CONFIG
+ fi
+}
+
+# Check for config file
+if [ -f $CONFIG ]; then
+ MODFOLDER=$(grep -A1 "[modfolder]" $CONFIG | tail -1)
+ else
+ modpath
+ MODFOLDER=$(grep -A1 '[modfolder]' $CONFIG | tail -1)
+fi
+
+# if nothing is entered after script then show usage
+if [ $# -eq 0 ]; then
+ usage
+ exit 1
+fi
+
+# If the input matches a directory then activate all within, otherwise activate specified module only
+if [ -d $MODFOLDER/$1* ]; then
+
+for fold in $( find $MODFOLDER/$1* -name "*.*" );
+ do activate $fold;
+done
+exit
+
+else
+
+for mod in $( find $MODFOLDER -name $1*.xzm);
+ do activate $mod;
+done
+exit
+fi
+
+# If this point is reached then the input entered did not match
+# a module or a folder and the script will exit gracefully.
+echo
+echo "Nothing found !!"
+echo
+exit
@@ -0,0 +1,136 @@
+#!/bin/bash
+# Activate a module, while running LiveCD.
+# Include it into live directory structure on the fly
+#
+# Author: Tomas M. <http://www.linux-live.org>
+# Modifications for Porteus by fanthom/brokenman
+
+MODULE=$(readlink -f "$1")
+
+# Make sure that only one (two for root) instance of 'activate' script is running
+pid=`ps a | egrep -v 'grep|xterm' | grep -c -w /opt/porteus-scripts/activate`
+while [ $pid -gt 3 ]; do
+ echo "too many activations - sleeping 1 sec..." && sleep 1
+ pid=`ps a | egrep -v 'grep|xterm' | grep -c -w /opt/porteus-scripts/activate`
+done
+
+# Switch to root
+if [ "$DISPLAY" ]; then
+ if [ `whoami` != "root" ]; then
+ xterm -T "Please enter root's password below" -e su -c "/opt/porteus-scripts/xactivate $MODULE && sleep 2"
+ exit
+ fi
+else
+ if [ `whoami` != "root" ]; then
+ echo "Please enter root's password below"
+ su -c "/opt/porteus-scripts/activate $MODULE"
+ exit
+ fi
+fi
+
+if [ "$2" = "-k" ]; then
+ CALLED_BY_GUI_HELPER=1
+fi
+
+if [ -e /opt/porteus-scripts/xactivate -a "$DISPLAY" -a ! "$CALLED_BY_GUI_HELPER" ]; then
+ exec /opt/porteus-scripts/xactivate "$MODULE" 2>/dev/null
+fi
+
+PATH=.:$(dirname $0):/usr/lib:$PATH
+. liblinuxlive || exit 3
+
+BASE=$(basename $1 2>/dev/null)
+if ismountpoint "/mnt/live/memory/images/$BASE"; then
+ echo "Module is already activated. Deactivate? Answer y/n"
+ read ans
+ if [ "$ans" = "y" ]; then
+ deactivate $BASE
+ exit
+ else
+ exit
+ fi
+fi
+
+if [ "$MODULE" = "" -o ! -e "$MODULE" -o -d "$MODULE" ]; then
+ echo
+ echo "Activate a module on the fly while running Linux Live"
+ echo "Usage: $0 module.xzm"
+ exit 1
+fi
+
+if [ "$(echo $MODULE | fgrep -i .xzm)" = "" ]; then
+ echo
+ echo "$(basename $MODULE): Module must end with .xzm"
+ exit 2
+fi
+
+IMAGES=/mnt/live/memory/images
+MODULES=/mnt/live/memory/modules
+
+# are we even using union?
+if [ "$(grep '^aufs / ' /proc/mounts)" = "" ]; then
+ echo "not in the live mode, can't continue. Try xzm2dir $MODULE /"
+ exit 4
+fi
+
+mkdir -p "$MODULES"
+
+# Test whether the module file is stored in union
+# if yes, then we must move it somewhere else (to RAM) else it can't be added
+if [ -e "/mnt/live/memory/changes/$(readlink -f "$MODULE")" ]; then
+ echo "module file is stored inside the union, moving to $MODULES first..."
+ TARGET="$MODULES/$(basename "$MODULE")"
+ mv "$MODULE" "$TARGET"
+ if [ $? -ne 0 ]; then
+ echo "error copying module to memory, not enough free RAM? try df" >&2
+ rm "$TARGET"
+ exit 6
+ fi
+ MODULE="$TARGET"
+fi
+
+# 'Stale NFS' workaround
+cd /etc
+
+MOD=$(union_insert_module / "$MODULE" $IMAGES)
+if [ $? -ne 0 ]; then echo "error inserting module to live filesystem" >&2; exit 3; fi
+MOD="$IMAGES/$(basename $MOD)"
+
+# All executables (but symlinks) in /etc/rc.d/init.d/ from this module will be started
+# with two arguments: "start" "activate".
+# This is done only by the 'activate' script, not in the case when the module is loaded
+# during OS startup (in that case, your distro is responsible for execution)
+#
+# For compatibility, /etc/init.d is also examined, but it's not recommended for you to put your startup scripts
+# there in your module
+find_n_run_scripts $MOD start activate
+
+# Rebuild the system configuration cache
+echo "Updating shared library links: /sbin/ldconfig"
+/sbin/ldconfig
+echo "Updating MIME database: /usr/bin/update-mime-database /usr/share/mime"
+/usr/bin/update-mime-database /usr/share/mime > /dev/null 2>&1
+
+# Update KDE menu
+kdeuser=`ps aux | grep /usr/bin/startkde | grep -v grep | cut -d " " -f1`
+if [ "$kdeuser" ]; then
+ echo "Updating KDE menu: kbuildsycoca"
+ for x in "$kdeuser"; do su --login $x -c "kbuildsycoca"; done
+fi
+
+# Update LXDE menu
+lxuser=`ps aux | grep lxsession | grep -v grep | cut -d " " -f1`
+if [ "$lxuser" ]; then
+ desktop=`find $MOD/usr/share/applications -name "*.desktop" | wc -l`
+ if [ "$desktop" != "0" ]; then
+ echo "Updating LXDE menu: rm ~/.cache/menus/*; lxpanelctl restart"
+ for x in "$lxuser"; do su --login $x -c "rm ~/.cache/menus/*; lxpanelctl restart"; done
+ fi
+fi
+
+# Make sure that we have at least one free loop device
+x=`grep /dev/loop /proc/mounts | tail -n1 | cut -d " " -f1 | sed 's@/dev/loop@@'`; let y=x+1
+if [ ! -e /dev/loop$y ]; then
+ echo "Adding new loop device: mknod /dev/loop$y b 7 $y"
+ mknod /dev/loop$y b 7 $y
+fi
@@ -0,0 +1,24 @@
+#!/bin/sh
+# script by fanthom
+
+# Switch to root
+if [ `whoami` != "root" ]; then
+ echo "Please enter your root password below"
+ su - -c "/opt/porteus-scripts/add_loop_devices"
+ exit
+fi
+
+# Variables
+c='\e[36m'
+r='\e[31m'
+e=`tput sgr0`
+
+[ "$1" = "" ] && echo -e $r"Enter number of loops as an argument. Example: add_loop_devices 15"$e && exit
+
+x=`ls -1 /dev/loop* | tail -n1 | sed 's@/dev/loop@@'`; let y=$x+$1
+while [ $x -le $y ]; do
+ mknod /dev/loop$y b 7 $y 2>/dev/null
+ let y=y-1
+done
+
+echo -e $c"Added $1 free loop devices"$e
@@ -0,0 +1,39 @@
+#!/bin/bash
+# script by fanthom
+
+# Switch to root
+if [ `whoami` != "root" ]; then
+ echo "Please enter your root password below"
+ su - -c "/opt/porteus-scripts/changes-time.sh"
+ exit
+fi
+
+# Variables
+c='\e[36m'
+r='\e[31m'
+e=`tput sgr0`
+changes=/mnt/live/memory/changes
+tmp=/tmp/work$$
+path=/root/changes$$
+
+clear
+echo -e ${c}"Enter time interval or press enter for keeping default value (3 minutes):"$e
+read int
+[ ! $int = "" ] && time=$int || time=3
+
+# Creating tmp dir
+mkdir $tmp
+
+# Locating and copying newly created/modified files except of /dev, /home, /mnt, /root and /tmp
+echo -e ${r}"Following folders will be excluded by default: /dev, /home, /mnt, /root, /tmp"$e
+file=`find $changes -mmin -$time | egrep -v "$changes/dev|$changes/home|$changes/mnt|$changes/root|$changes/tmp"`
+for x in $file; do cp -P --parents $x $tmp 2> /dev/null; done
+
+# Removing all files which are recreated by Porteus during boot anyway and may cause troubles during activation "on the fly"
+rm $tmp/$changes/etc/ld.so.cache $tmp/$changes/lib/modules/2.6.*/* $tmp/$changes/usr/share/applications/mimeinfo.cache 2>/dev/null
+rm -r $tmp/$changes/usr/share/mime 2>/dev/null
+
+# Moving all stuff to the final destination
+mv $tmp/$changes $path
+
+echo -e ${c}"all files created/modified in last $time minutes were copied to $path folder"$e
@@ -0,0 +1,58 @@
+#!/bin/bash
+# script by fanthom
+
+# Variables
+c='\e[36m'
+r='\e[31m'
+e=`tput sgr0`
+dir="$1/base/000-kernel.xzm"
+md5=`which md5sum`
+out=/tmp/md5sums.txt$$
+
+# Let's start
+if [ "$md5" = "" ]; then
+ echo -e "${r}md5sum utility is missing, exiting..."$e
+ exit
+fi
+
+if [ ! -e "$dir" ]; then
+ echo -e "${r}Please enter the full path to where you placed your porteus data folder, for example: /mnt/sdb3/porteus"$e | fmt -w 80
+ exit
+fi
+
+cd $1
+for x in `find ../boot/initrd.xz` `find ../boot/vmlinuz`; do
+ md5sum $x >> $out
+done
+
+for x in `find ./base/* | sort`; do
+ [ -d $x ] || md5sum $x >> $out
+done
+
+echo
+num=`grep -c / md5sums.txt`; x=1
+while [ $x -le $num ]; do
+ file=`awk NR==$x md5sums.txt | cut -d " " -f2-`
+ first=`awk NR==$x md5sums.txt | cut -d " " -f1`
+ second=`grep $file $out | cut -d " " -f1`
+ if [ "$first" == "$second" ];then
+ echo -e "checking md5sum for $file ${c}ok"$e
+ else
+ echo -e "checking md5sum for $file ${r}fail!"$e
+ fail="yes"
+ fi
+ let x=x+1
+done
+rm $out
+
+echo
+if [ "$fail" ]; then
+echo -e "${r}Some md5sums don't match or some files from default ISO are missing, please check above...
+Be aware that vmlinuz, initrd.xz, 000-kernel.xzm and 001-core.xzm are the most important, and booting wont be possible when they are missing."$e | fmt -w 80
+
+else
+ echo -e "${c}All md5sums are ok, you should have no problems with booting Porteus!"$e
+fi
+
+echo -e "${c}Press enter to exit"$e
+read
Oops, something went wrong.

0 comments on commit 31cedc6

Please sign in to comment.