mirror of
https://github.com/flynx/post-install.git
synced 2025-10-28 02:00:08 +00:00
more refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
92f47b689a
commit
da9497c5ff
53
post-install
53
post-install
@ -7,6 +7,7 @@
|
|||||||
# - edit system config files
|
# - edit system config files
|
||||||
# - might be a good idea to add gui/no-gui options...
|
# - might be a good idea to add gui/no-gui options...
|
||||||
# - ssh-keygen...
|
# - ssh-keygen...
|
||||||
|
# - add --system and --user flags to only do system/user stuff...
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
@ -27,8 +28,22 @@ CMD=$(basename $0)
|
|||||||
SYSTEM_RC=${0}rc
|
SYSTEM_RC=${0}rc
|
||||||
USER_RC=~/.${CMD}rc
|
USER_RC=~/.${CMD}rc
|
||||||
|
|
||||||
|
# XXX do we need to split user and system scripts???
|
||||||
SCRIPT_DIR=${0}.d/
|
SCRIPT_DIR=${0}.d/
|
||||||
MACHINE_SCRIPT_DIR=$SCRIPT_DIR/michine/
|
USER_SCRIPT_DIR=${0}.d/user/
|
||||||
|
|
||||||
|
# System info...
|
||||||
|
if ! [ -z "$(type -t dmidecode )" ] ; then
|
||||||
|
# XXX should we be more specific here and include model number??
|
||||||
|
PLATFORM=$( dmidecode \
|
||||||
|
| grep -A3 '^System Information' \
|
||||||
|
| grep 'Version:' \
|
||||||
|
| sed 's/\s*Version:\s*//' )
|
||||||
|
else
|
||||||
|
PLATFORM=unknown
|
||||||
|
fi
|
||||||
|
|
||||||
|
PLATFORM_SCRIPT_DIR=${SCRIPT_DIR}/platform/${PLATFORM}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -53,6 +68,7 @@ FEATURES=(
|
|||||||
|
|
||||||
scripts
|
scripts
|
||||||
platform-scripts
|
platform-scripts
|
||||||
|
user-scripts
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -199,6 +215,7 @@ ALL_FEATURES=(
|
|||||||
# keep this last...
|
# keep this last...
|
||||||
scripts
|
scripts
|
||||||
platform-scripts
|
platform-scripts
|
||||||
|
user-scripts
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -349,10 +366,7 @@ function feature-snapshots(){ (
|
|||||||
|
|
||||||
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# XXX split these into:
|
# XXX skip scripts starting in "-"
|
||||||
# - system
|
|
||||||
# - machine -- get platform name
|
|
||||||
# - user
|
|
||||||
function feature-scripts(){ (
|
function feature-scripts(){ (
|
||||||
if ! [ -z "$1" ] ; then
|
if ! [ -z "$1" ] ; then
|
||||||
local dir=$1
|
local dir=$1
|
||||||
@ -373,18 +387,11 @@ function feature-scripts(){ (
|
|||||||
) }
|
) }
|
||||||
|
|
||||||
function feature-platform-scripts(){
|
function feature-platform-scripts(){
|
||||||
# System info...
|
feature-scripts "$PLATFORM_SCRIPT_DIR"
|
||||||
if ! [ -z "$(type -t dmidecode )" ] ; then
|
}
|
||||||
# XXX should we be more specific here and include model number??
|
|
||||||
local platform=$( dmidecode \
|
|
||||||
| grep -A3 '^System Information' \
|
|
||||||
| grep 'Version:' \
|
|
||||||
| sed 's/\s*Version:\s*//' )
|
|
||||||
else
|
|
||||||
local platform=default
|
|
||||||
fi
|
|
||||||
|
|
||||||
feature-scripts "$MACHINE_SCRIPT_DIR/$platform"
|
function feature-user-scripts(){
|
||||||
|
feature-scripts "$USER_SCRIPT_DIR"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -521,6 +528,10 @@ Feature list manipulation:
|
|||||||
-FEATURE - remove FEATURE from list
|
-FEATURE - remove FEATURE from list
|
||||||
+FEATURE - add FEATURE to lost
|
+FEATURE - add FEATURE to lost
|
||||||
|
|
||||||
|
Helpers:
|
||||||
|
--make-platform-dir - make platform directory for current platform
|
||||||
|
and exit.
|
||||||
|
|
||||||
|
|
||||||
Default features:
|
Default features:
|
||||||
${FEATURES[@]}
|
${FEATURES[@]}
|
||||||
@ -585,7 +596,17 @@ while ! [ -z "$1" ] ; do
|
|||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
# helpers...
|
||||||
|
--make-platform-dir)
|
||||||
|
echo "# Patform script dir: $PLATFORM_SCRIPT_DIR"
|
||||||
|
[ -d "$PLATFORM_SCRIPT_DIR" ] \
|
||||||
|
|| @ mkdir -p "$PLATFORM_SCRIPT_DIR"
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
|
||||||
|
|
||||||
# feature manipulation...
|
# feature manipulation...
|
||||||
|
# NOTE: keep these last...
|
||||||
+all)
|
+all)
|
||||||
FEATURES=( ${ALL_FEATURES[@]} )
|
FEATURES=( ${ALL_FEATURES[@]} )
|
||||||
shift
|
shift
|
||||||
|
|||||||
1
post-install.d/platform/README
Normal file
1
post-install.d/platform/README
Normal file
@ -0,0 +1 @@
|
|||||||
|
This directory contains machine-specific scripts.
|
||||||
Loading…
x
Reference in New Issue
Block a user