mirror of
https://github.com/tuxbox-neutrino/buildenv.git
synced 2025-08-26 15:02:58 +02:00
init.sh: Refactor script configuration and directory paths
- Update DIST_BASEDIR assignment to use $DIST_DIR for improved clarity and consistency in directory management. - Rename HTTPD_DIST_HOSTNAME and HTTPD_DIST_DIR to UPDATE_SERVER_URL and DIST_DIR respectively, across the script to better reflect their purpose and usage. - Introduce LOCAL_CONFIG_FILE_INC_PATH variable initialization in the global scope for enhanced script modularity and maintainability. - Adjust getopt configuration to align with the renamed and newly introduced variables.
This commit is contained in:
@@ -270,7 +270,6 @@ function create_local_config () {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# modify or upgrade config files inside conf directory
|
# modify or upgrade config files inside conf directory
|
||||||
LOCAL_CONFIG_FILE_INC_PATH=$BASEPATH/local.conf.common.inc
|
|
||||||
if test -f $LOCAL_CONFIG_FILE_INC_PATH; then
|
if test -f $LOCAL_CONFIG_FILE_INC_PATH; then
|
||||||
|
|
||||||
if test -f $LOCAL_CONFIG_FILE_PATH; then
|
if test -f $LOCAL_CONFIG_FILE_PATH; then
|
||||||
@@ -359,7 +358,7 @@ function create_local_config () {
|
|||||||
function create_dist_tree () {
|
function create_dist_tree () {
|
||||||
|
|
||||||
# create dist dir
|
# create dist dir
|
||||||
DIST_BASEDIR="$BASEPATH/dist/$IMAGE_VERSION"
|
DIST_BASEDIR="$DIST_DIR/$IMAGE_VERSION"
|
||||||
if test ! -d "$DIST_BASEDIR"; then
|
if test ! -d "$DIST_BASEDIR"; then
|
||||||
my_echo -e "\033[37;1mcreate dist directory:\033[0m $DIST_BASEDIR"
|
my_echo -e "\033[37;1mcreate dist directory:\033[0m $DIST_BASEDIR"
|
||||||
do_exec "mkdir -p $DIST_BASEDIR"
|
do_exec "mkdir -p $DIST_BASEDIR"
|
||||||
|
36
init.sh
36
init.sh
@@ -14,8 +14,8 @@ false="0"
|
|||||||
DO_UPDATE=$false
|
DO_UPDATE=$false
|
||||||
DO_RESET=$false
|
DO_RESET=$false
|
||||||
FILES_DIR="$BASEPATH/files"
|
FILES_DIR="$BASEPATH/files"
|
||||||
HTTPD_DIST_HOSTNAME="localhost"
|
UPDATE_SERVER_URL="http://localhost"
|
||||||
HTTPD_DIST_DIR="$BASEPATH/dist"
|
DIST_DIR="$BASEPATH/dist"
|
||||||
USER_CALL="$0 $@"
|
USER_CALL="$0 $@"
|
||||||
|
|
||||||
## Basename of this script
|
## Basename of this script
|
||||||
@@ -31,6 +31,7 @@ rm -f $TMP_LOGFILE
|
|||||||
LOGFILE_NAME="$NAME"_"$TIMESTAMP.log"
|
LOGFILE_NAME="$NAME"_"$TIMESTAMP.log"
|
||||||
LOGFILE=$LOG_PATH/$LOGFILE_NAME
|
LOGFILE=$LOG_PATH/$LOGFILE_NAME
|
||||||
LOGFILE_LINK=$LOG_PATH/$NAME.log
|
LOGFILE_LINK=$LOG_PATH/$NAME.log
|
||||||
|
LOCAL_CONFIG_FILE_INC_PATH=$BASEPATH/local.conf.common.inc
|
||||||
echo "" > $LOGFILE
|
echo "" > $LOGFILE
|
||||||
ln -sf $LOGFILE $LOGFILE_LINK
|
ln -sf $LOGFILE $LOGFILE_LINK
|
||||||
my_echo "true" "$USER_CALL"
|
my_echo "true" "$USER_CALL"
|
||||||
@@ -110,8 +111,8 @@ show_help() {
|
|||||||
echo ""
|
echo ""
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " -m, --machine $HINT_MACHINES"
|
echo " -m, --machine $HINT_MACHINES"
|
||||||
echo " --httpd-dist-hostname IP or hostname (optional with portname) to define the update server address for local.conf.common.inc, default: $HTTPD_DIST_HOSTNAME"
|
echo " --update-url URL (IP, hostname or domain, optional with portnumber) to define the update server address for $LOCAL_CONFIG_FILE_INC_PATH, default: $UPDATE_SERVER_URL"
|
||||||
echo " --httpd-dist-dir Directory where the local httpd server find the deployed images and packages, default: $HTTPD_DIST_DIR"
|
echo " --dist-dir Directory where to find the deployed images and packages, default: $DIST_DIR"
|
||||||
echo " -p, --project-url Project-URL where to find project meta layers,"
|
echo " -p, --project-url Project-URL where to find project meta layers,"
|
||||||
echo " e.g. for read and write access: git@github.com:tuxbox-neutrino, default = $PROJECT_URL"
|
echo " e.g. for read and write access: git@github.com:tuxbox-neutrino, default = $PROJECT_URL"
|
||||||
echo " -u, --update Update your project meta layers"
|
echo " -u, --update Update your project meta layers"
|
||||||
@@ -119,11 +120,11 @@ show_help() {
|
|||||||
echo " -i, --id-rsa-file Path to your preferred id rsa file, default: users id rsa file, e.g. $HOME/.ssh/id_rsa"
|
echo " -i, --id-rsa-file Path to your preferred id rsa file, default: users id rsa file, e.g. $HOME/.ssh/id_rsa"
|
||||||
echo ""
|
echo ""
|
||||||
echo " -h, --help Show this help"
|
echo " -h, --help Show this help"
|
||||||
echo " --version Show version information"
|
echo " --version Show version information"
|
||||||
}
|
}
|
||||||
|
|
||||||
## Processing command line arguments
|
## Processing command line arguments
|
||||||
TEMP=$(getopt -o rup:m:i:h --long reset,httpd-dist-hostname:,httpd-dist-dir:,update,project-url:,machine:,id-rsa-file,help,version -n 'init' -- "$@")
|
TEMP=$(getopt -o rup:m:i:h --long reset,update-url:,dist-dir:,update,project-url:,machine:,id-rsa-file,help,version -n 'init' -- "$@")
|
||||||
if [ $? != 0 ] ; then
|
if [ $? != 0 ] ; then
|
||||||
my_echo "Error while process arguments" >&2
|
my_echo "Error while process arguments" >&2
|
||||||
show_help
|
show_help
|
||||||
@@ -142,10 +143,10 @@ while true ; do
|
|||||||
MACHINE="$2"; shift 2 ;;
|
MACHINE="$2"; shift 2 ;;
|
||||||
-i|--id-rsa-file)
|
-i|--id-rsa-file)
|
||||||
GIT_SSH_KEYFILE="$2"; shift 2 ;;
|
GIT_SSH_KEYFILE="$2"; shift 2 ;;
|
||||||
--httpd-dist-hostname)
|
--update-url)
|
||||||
HTTPD_DIST_HOSTNAME="$2"; shift 2 ;;
|
UPDATE_SERVER_URL="$2"; shift 2 ;;
|
||||||
--httpd-dist-dir)
|
--dist-dir)
|
||||||
HTTPD_DIST_DIR="$2"; shift 2 ;;
|
DIST_DIR="$2"; shift 2 ;;
|
||||||
-u|--update)
|
-u|--update)
|
||||||
DO_UPDATE="$true"; shift ;;
|
DO_UPDATE="$true"; shift ;;
|
||||||
-r|--reset)
|
-r|--reset)
|
||||||
@@ -172,9 +173,9 @@ my_echo "-----------------------------------------------------------------------
|
|||||||
my_echo "Buildenv Version: \033[37;1m$INIT_VERSION\033[0m "
|
my_echo "Buildenv Version: \033[37;1m$INIT_VERSION\033[0m "
|
||||||
my_echo "Image Version: \033[37;1m$IMAGE_VERSION\033[0m "
|
my_echo "Image Version: \033[37;1m$IMAGE_VERSION\033[0m "
|
||||||
my_echo "Compatible OE-branch: \033[37;1m$COMPATIBLE_BRANCH\033[0m "
|
my_echo "Compatible OE-branch: \033[37;1m$COMPATIBLE_BRANCH\033[0m "
|
||||||
my_echo "Buildroot dir: \033[37;1m$BUILD_ROOT_DIR\033[0m "
|
my_echo "Buildroot directory: \033[37;1m$BUILD_ROOT_DIR\033[0m "
|
||||||
my_echo "httpd Dist hostname: \033[37;1m$HTTPD_DIST_HOSTNAME\033[0m "
|
my_echo "Update Server URL: \033[37;1m$UPDATE_SERVER_URL\033[0m "
|
||||||
my_echo "httpd Dist directory: \033[37;1m$HTTPD_DIST_DIR\033[0m "
|
my_echo "Dist directory: \033[37;1m$DIST_DIR\033[0m "
|
||||||
my_echo "Configured Machine(s): \033[37;1m$MACHINE\033[0m "
|
my_echo "Configured Machine(s): \033[37;1m$MACHINE\033[0m "
|
||||||
my_echo "Project Repository URL: \033[37;1m$PROJECT_URL\033[0m "
|
my_echo "Project Repository URL: \033[37;1m$PROJECT_URL\033[0m "
|
||||||
my_echo "SRCREV Yocto: \033[37;1m$YOCTO_SRCREV\033[0m "
|
my_echo "SRCREV Yocto: \033[37;1m$YOCTO_SRCREV\033[0m "
|
||||||
@@ -268,9 +269,10 @@ fi
|
|||||||
|
|
||||||
## Configure buildsystem
|
## Configure buildsystem
|
||||||
# Create included config file from sample file
|
# Create included config file from sample file
|
||||||
if test ! -f $BASEPATH/local.conf.common.inc; then
|
if test ! -f $LOCAL_CONFIG_FILE_INC_PATH; then
|
||||||
my_echo "\033[37;1mCONFIG:\033[0mCreate $BASEPATH/local.conf.common.inc as include file for local layer configuration ..."
|
my_echo "\033[37;1mCONFIG:\033[0mCreate $LOCAL_CONFIG_FILE_INC_PATH as include file for local layer configuration ..."
|
||||||
do_exec "cp -v $BASEPATH/local.conf.common.inc.sample $BASEPATH/local.conf.common.inc"
|
do_exec "cp -v $LOCAL_CONFIG_FILE_INC_PATH.sample $LOCAL_CONFIG_FILE_INC_PATH"
|
||||||
|
do_exec "sed -i -e 's|#UPDATE_SERVER_URL = \"http://@hostname@\"|UPDATE_SERVER_URL = \"${UPDATE_SERVER_URL}\"|' $LOCAL_CONFIG_FILE_INC_PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create configuration for machine
|
# Create configuration for machine
|
||||||
@@ -292,7 +294,7 @@ create_dist_tree;
|
|||||||
my_echo "\033[37;1mLocal setup for package online update.\033[0m"
|
my_echo "\033[37;1mLocal setup for package online update.\033[0m"
|
||||||
my_echo "------------------------------------------------------------------------------------------------"
|
my_echo "------------------------------------------------------------------------------------------------"
|
||||||
my_echo "If you want to use online update for your devices, please configure your webserver and use the"
|
my_echo "If you want to use online update for your devices, please configure your webserver and use the"
|
||||||
my_echo "content of $HTTPD_DIST_DIR"
|
my_echo "content of $DIST_DIR"
|
||||||
my_echo "as destination for your webserver (e.g. apache, nginx, lighttpd or what ever you want)"
|
my_echo "as destination for your webserver (e.g. apache, nginx, lighttpd or what ever you want)"
|
||||||
my_echo ""
|
my_echo ""
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user