Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 71ab44b60e
Fetching contributors…

Cannot retrieve contributors at this time

241 lines (208 sloc) 5.629 kb
#!/bin/bash
# #
# misc.lunar - Lunar subroutines #
# #
############################################################
# #
# this WAS the subroutines of a source based Linux distro, #
# calls Sorcerer GNU/Linux, or SGL. SGL is no longer #
# available with GPL license. Since this script was taken #
# before licensing scheme change, no legal problems I #
# guess. #
# #
# the code is re-written for Lunar. The previous Copyright #
# notices are kept; just in case some code is left :=) #
# Kagan Kongar <kongar@tsrsb.org.tr>, 20020519 #
# #
############################################################
# #
# Copyright 2001 by Kyle Sallee #
# #
# Parts Copyrighted Hendrik Visage 2002 under GPLv2 #
# #
# Parts Copyrighted Kagan Kongar 2002 under GPLv2 #
# #
############################################################
# function : ld_add
# usage : ld_add <directory>
# purpose : Add a path to ld.so.conf
ld_add() {
debug_msg "ld_add ($@)"
if [ ! -z "$1" ] && [ -d "$1" ] ; then
if ! grep -q "$1" /etc/ld.so.conf; then
verbose_msg "Adding $1 to ld.so.conf"
echo "$1" >> /etc/ld.so.conf
ldconfig
fi
fi
}
# function : ld_remove
# usage : ld_remove <directory>
# purpose : Remove a path from ld.so.conf
ld_remove() {
debug_msg "ld_remove ($@)"
if [ ! -z "$1" ]; then
if grep -q "$1" /etc/ld.so.conf ; then
TMP_LD_CONF=$(temp_create "ldsoconf")
verbose_msg "Removing $1 from ld.so.conf"
grep -v "$1" /etc/ld.so.conf > $TMP_LD_CONF
cat "$TMP_LD_CONF" > /etc/ld.so.conf
ldconfig
temp_destroy $TMP_LD_CONF
fi
fi
}
# function : directories
# usage : VARIABLE=`directories < dirlistfile`
# purpose : to determine the directories from a given list
directories() {
debug_msg "directories ($@)"
local ITEM
while read ITEM ; do
if [ -d "$ITEM" ] && [ ! -h "$ITEM" ] ; then
echo "$ITEM"
fi
done
}
# function : files
# usage : VARIABLE=`files < dirlistfile`
# purpose : to determine the ordinary files from a given list
files() {
debug_msg "files ($@)"
local ITEM
while read ITEM ; do
if [ -f "$ITEM" ] && [ ! -h "$ITEM" ] ; then
echo "$ITEM"
fi
done
}
# function : sysmlinks
# usage : VARIABLE=`symlinks < dirlistfile`
# purpose : to determine the symbolic links from a given list
symlinks() {
debug_msg "symlinks ($@)"
local ITEM
while read ITEM ; do
if [ -h "$ITEM" ] ; then
echo "$ITEM"
fi
done
}
# function : dirnames
# usage : VARIABLE=`dirnames < dirlistfile`
# purpose : info about the real locations of symlinks
dirnames() {
debug_msg "dirnames ($@)"
local FILE
while read FILE ; do
dirname "$FILE"
done
}
# function : exists
# usage : VARIABLE=`exists < dirlistfile`
# purpose : filter out the non-existent files in a list
exists() {
debug_msg "exists ($@)"
local ITEM
while read ITEM ; do
if [ -e "$ITEM" ] || [ -L "$ITEM" ]; then
echo "$ITEM"
fi
done
}
# function : filter
# usage : filter $FILE
# purpose : filter stdin with files/dirs/symlinks provided in file $1.
filter() {
debug_msg "filter ($@)"
local TMP_GREPRE
if [ -f "$1" ] ; then
TMP_GREPRE=$(temp_create "fgrep")
directories < $1 | sed -e 's:^:^:g' -e 's:$:/:g' > $TMP_GREPRE
files < $1 | sed -e 's:^:^:g' -e 's:$:\$:g' >> $TMP_GREPRE
symlinks < $1 | sed -e 's:^:^:g' -e 's:$:\$:g' >> $TMP_GREPRE
read
grep -v -f "$TMP_GREPRE"
temp_destroy $TMP_GREPRE
else
cat -
fi
}
unmap_device()
{
debug_msg "unmap_device($@)"
local DEVICE REAL
REAL=$(readlink -f $1)
for DEVICE in $(ls -1d /dev/[hs]d* 2> /dev/null); do
if [[ "$(readlink -f $DEVICE)" == "$REAL" ]]; then
echo $DEVICE
return 0
fi
done
echo $1
return 0
}
find_pam_aware() {
debug_msg "find_pam_aware ($@)"
local MODULE SECTION
for MODULE in $(list_installed); do
SECTION=$(find_section $MODULE)
if [ -d "$MOONBASE/$SECTION/$MODULE/pam.d" ] &&
[ "$MODULE" != "Linux-PAM" ]; then
echo $MODULE
fi
done < $MODULE_STATUS
}
custom_filters()
{
local FILE
if [[ "${COMPRESS_MANPAGES:-on}" == "on" ]]; then
while read FILE; do
if [[ -f "$FILE" ]] ; then
if echo "$FILE" | grep '^/usr/share/man/.*\..$' | grep -q -v '\.gz$'; then
gzip -9 < "$FILE" > "$FILE.gz"
debug_msg "Compressing man page \"$FILE\""
rm -f "$FILE"
echo "$FILE.gz"
else
echo "$FILE"
fi
else
echo "$FILE"
fi
done
else
cat -
fi
}
last_kernel()
{
if [ -f /usr/src/linux/include/linux/utsrelease.h ]; then
grep UTS_RELEASE /usr/src/linux/include/linux/utsrelease.h | cut -d'"' -f2
else
grep UTS_RELEASE /usr/src/linux/include/linux/version.h | cut -d'"' -f2
fi
}
xzbz_file()
{
local FILE FILE_BZ
FILE="$1.xz"
if [ ! -f $FILE ] ; then
FILE_BZ="$1.bz2"
if [ -f $FILE_BZ ] ; then
FILE="$FILE_BZ"
fi
fi
echo $FILE
}
xzbz()
{
local XZBZ
case $(file -b $2 | cut -d' ' -f1) in
bzip2) XZBZ=bzip2 ;;
gzip) XZBZ=gzip ;;
XZ) XZBZ=xz ;;
*) XZBZ=xz ;;
esac
$XZBZ "$@"
}
Jump to Line
Something went wrong with that request. Please try again.