update rootfs
This commit is contained in:
1 parent
0ea96d011c
commit
c52cf00e6d
17 files changed
+617
-163
No files matched your search
File renamed without changes.
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
#--- import colors ---
|
#--- import colors ---
|
||||||
. /etc/init.d/colors.sh
|
. /etc/init.d/funcs/colors.sh
|
||||||
#---------------------
|
#---------------------
|
||||||
|
|
||||||
#---------------------- rc function to poweron or poweroff ------------
|
#---------------------- rc function to poweron or poweroff ------------
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
. /etc/init.d/colors.sh
|
. /etc/init.d/funcs/colors.sh
|
||||||
. /etc/init.d/init-funcs
|
. /etc/init.d/funcs/init-funcs
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
. /etc/init.d/init-funcs
|
. /etc/init.d/funcs/init-funcs
|
||||||
. /etc/init.d/colors.sh
|
. /etc/init.d/funcs/colors.sh
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
@@ -14,7 +14,9 @@ case "$1" in
|
|||||||
printf "$UYELLOW Stopping netowrking\n$RESET"
|
printf "$UYELLOW Stopping netowrking\n$RESET"
|
||||||
/sbin/ifdown -a
|
/sbin/ifdown -a
|
||||||
check $? "Stop networking"
|
check $? "Stop networking"
|
||||||
rm /var/run/networking.pid
|
if [ -f /var/run/networking.pid ]; then
|
||||||
|
rm /var/run/networking.pid
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
restart|reload)
|
restart|reload)
|
||||||
$0 stop
|
$0 stop
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
. /etc/init.d/init-funcs
|
. /etc/init.d/funcs/init-funcs
|
||||||
rc
|
rc
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
. /etc/init.d/init-funcs
|
. /etc/init.d/funcs/init-funcs
|
||||||
. /etc/init.d/colors.sh
|
. /etc/init.d/funcs/colors.sh
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
nameserver 10.0.2.3
|
||||||
Executable
+287
@@ -0,0 +1,287 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
########## #### ####
|
||||||
|
########## #### ####
|
||||||
|
## ## ## ## ## ##
|
||||||
|
## ## ## ## ## ##
|
||||||
|
########## ## ## ## - PACKAGE MANAGER FOR SIMPLE LINUX
|
||||||
|
########## ## ## ## - AUTHOR -- TOLA MIRONCENKO
|
||||||
|
## ## ##
|
||||||
|
## ## ##
|
||||||
|
## ## ##
|
||||||
|
## ## ##
|
||||||
|
|
||||||
|
#----- colors -------
|
||||||
|
Green='\033[0;32m'
|
||||||
|
Color_off='\033[0m'
|
||||||
|
Red='\033[0;31m'
|
||||||
|
Bred='\033[1;31m'
|
||||||
|
Yellow='\033[1;33m'
|
||||||
|
White='\033[0;37m'
|
||||||
|
Bwhite='\033[1;37m'
|
||||||
|
#--------------------
|
||||||
|
|
||||||
|
#---------------- variables --------------------------
|
||||||
|
rootdir=/
|
||||||
|
repofile=$rootdir/etc/pm/repo
|
||||||
|
packagesqueryfile=$rootdir/usr/share/pm/query
|
||||||
|
reposquerydir=$rootdir/usr/share/pm/repos
|
||||||
|
cachedpkgdir=$rootdir/var/cache/pm/pkg
|
||||||
|
installedpackagesdir=$rootdir/usr/share/pm/packages
|
||||||
|
#-----------------------------------------------------
|
||||||
|
|
||||||
|
#---------------- check root priveleges function ------------------------
|
||||||
|
checkroot() {
|
||||||
|
if [[ $(id -u) != 0 ]]; then
|
||||||
|
printf "$Yellow**$Bred error:$Color_off you must be root\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
checkroot
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#----------------- add(install) package function ------------------------
|
||||||
|
add() {
|
||||||
|
if [[ "$1" == "" ]]; then
|
||||||
|
help
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
for i in $*; do
|
||||||
|
if [[ "$i" == "add" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
for i in $*; do
|
||||||
|
if [[ "$i" == "add" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
down $i
|
||||||
|
done
|
||||||
|
for i in $*; do
|
||||||
|
if [[ "$i" == "add" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
unpack $cachedpkgdir/$i.pkg.gz
|
||||||
|
done
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#-------------------- download package without install function ---------
|
||||||
|
down() {
|
||||||
|
if [[ ! $1 ]]; then
|
||||||
|
help
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
servers=$(cat $repofile)
|
||||||
|
for i in $servers; do
|
||||||
|
serverdir=$(echo $i | sed -e "/http:\/\//s///")
|
||||||
|
repoquery=$(cat $reposquerydir/$serverdir/query | sed -e '/.pkg.gz/s///')
|
||||||
|
for j in $repoquery; do
|
||||||
|
if [[ $j == $1 ]]; then
|
||||||
|
if [ ! -f $cachedpkgdir/$1.pkg.gz ]; then
|
||||||
|
printf "$Yellow**$Color_off Downloading $Yellow$serverdir: $Bwhite$j\n$Color_off"
|
||||||
|
wget $i/$1.pkg.gz -P $cachedpkgdir
|
||||||
|
if [[ "$?" == "0" ]]; then
|
||||||
|
printf "$Yellow**$Green successful downloaded $1\n$Color_off"
|
||||||
|
return
|
||||||
|
else
|
||||||
|
printf "$Yellow**$Red error:$Color_off can't download package\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
printf "$Yellow**$Green successful downloaded $1\n$Color_off"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
# exit 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
printf "$Yellow**$Red error:$Color_off can't find package $1\n"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#-------------------- unpack local package archive ----------------------
|
||||||
|
unpack() {
|
||||||
|
packagename=$(echo $1 | sed -e "/.gz/s///")
|
||||||
|
packagename=${packagename#*pkg/}
|
||||||
|
printf "$Yellow**$Green Installing ${packagename%.pkg*}\n$Color_off"
|
||||||
|
if [[ "$(cat $packagesqueryfile | grep ${packagename%.pkg*})" != "" ]]; then
|
||||||
|
printf "$Yellow**$Color_off Package already installed:$Yellow reinstalling\n"
|
||||||
|
fi
|
||||||
|
tar -xvf $1 -C $rootdir/tmp &> /dev/null
|
||||||
|
cd $rootdir/tmp/$packagename
|
||||||
|
mkdir $installedpackagesdir/$packagename &> /dev/null
|
||||||
|
mv -v list $installedpackagesdir/$packagename &> /dev/null
|
||||||
|
cp -rv ./* $rootdir &> /dev/null
|
||||||
|
if [ -f $rootdir/tmp/$packagename/post_install ]; then
|
||||||
|
sh -c $rootdir/tmp/$packagename/post_install
|
||||||
|
fi
|
||||||
|
if [[ "$(cat $packagesqueryfile | grep ${packagename%.pkg*})" == "" ]]; then
|
||||||
|
echo ${packagename%.pkg*} >> $packagesqueryfile
|
||||||
|
fi
|
||||||
|
rm -rv $rootdir/tmp/$packagename &> /dev/null
|
||||||
|
printf "$Yellow**$Green Installed ${packagename%.pkg*} successful\n$Color_off"
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#------------------ delete package function -----------------------------
|
||||||
|
del() {
|
||||||
|
printf "$Yellow**$Green deleting\n$Color_off"
|
||||||
|
for i in $*; do
|
||||||
|
if [[ "$i" == "del" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
printf "$Yellow**$Green deleting $i\n$Color_off"
|
||||||
|
if [ ! -f $installedpackagesdir/$i.pkg/list ]; then
|
||||||
|
printf "$Yellow**$Bred error:$Color_off package not installed\n"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
rm -v $rootdir/$(cat $installedpackagesdir/$i.pkg/list) &> /dev/null
|
||||||
|
rm -rv $installedpackagesdir/$i.pkg &> /dev/null
|
||||||
|
sed -i "/$i/d" $packagesqueryfile
|
||||||
|
printf "$Yellow**$Green delete $i successful\n$Color_off"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#------------------- list files in package function ---------------------
|
||||||
|
list() {
|
||||||
|
if [[ "$1" == "" ]]; then
|
||||||
|
help
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
if [[ "$(cat $packagesqueryfile | grep $1)" == "" ]]; then
|
||||||
|
printf "$Yellow**$Bred error:$Color_off package is not installed\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
filelist=$(cat $installedpackagesdir/$1.pkg/list)
|
||||||
|
for i in $filelist; do
|
||||||
|
printf "$Yellow$1: $Bwhite$i$Color_off\n"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#------------------- show installed packages function -------------------
|
||||||
|
query() {
|
||||||
|
packagesquery=$(cat $packagesqueryfile)
|
||||||
|
if [[ "$packagesquery" == "" ]]; then
|
||||||
|
printf "$Yellow**$Bwhite No installed packages\n"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
printf "$packagesquery\n"
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#--------------------- show help function -------------------------------
|
||||||
|
help() {
|
||||||
|
printf "
|
||||||
|
$Yellow**$Green pm usage$Color_off :
|
||||||
|
$Bwhite pm add [package name] - download and install from repository
|
||||||
|
pm unpack [/path/to/package/archive] - unpack(install) from local package archive
|
||||||
|
pm down [package name] - download package from repository without install
|
||||||
|
pm del [package name] - delete package
|
||||||
|
pm list [package name] - list files in package
|
||||||
|
pm search [package name] - search package in repository
|
||||||
|
pm query - show installed packages
|
||||||
|
pm help - this help message
|
||||||
|
pm clear - clear all package archives from cached packages directory
|
||||||
|
pm sync - synchronize repository
|
||||||
|
|
||||||
|
$Yellow**$Green examples$Color_off :
|
||||||
|
$Bwhite pm add dnsmasq
|
||||||
|
pm unpack ./dnsmasq.pkg.gz
|
||||||
|
pm down dnsmasq
|
||||||
|
pm search dnsmasq
|
||||||
|
pm help
|
||||||
|
pm clear
|
||||||
|
pm sync
|
||||||
|
pm del dnsmasq
|
||||||
|
pm list dnsmasq
|
||||||
|
pm query
|
||||||
|
\n$Color_off"
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#------------------- sync repo function ---------------------------------
|
||||||
|
sync() {
|
||||||
|
servers=$(cat $repofile)
|
||||||
|
for i in $servers; do
|
||||||
|
serverdir=$(echo $i | sed -e "/http:\//s///")
|
||||||
|
mkdir $reposquerydir/$serverdir &> /dev/null
|
||||||
|
wget $i/query -O $reposquerydir/$serverdir/query &> /dev/null
|
||||||
|
done
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#----------------- search package in repo function ----------------------
|
||||||
|
search() {
|
||||||
|
servers=$(cat $repofile)
|
||||||
|
if [[ ! $1 ]]; then
|
||||||
|
for i in $servers; do
|
||||||
|
serverdir=$(echo $i | sed -e "/http:\/\//s///")
|
||||||
|
repoquery=$(cat $reposquerydir/$serverdir/query | sed -e '/.pkg.gz/s///')
|
||||||
|
for j in $repoquery; do
|
||||||
|
printf "$Yellow$serverdir: $Bwhite$j\n$Color_off"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
for i in $servers; do
|
||||||
|
serverdir=$(echo $i | sed -e "/http:\/\//s///")
|
||||||
|
repoquery=$(cat $reposquerydir/$serverdir/query | sed -e '/.pkg.gz/s///')
|
||||||
|
for j in $repoquery; do
|
||||||
|
if [[ $j == $1 ]]; then
|
||||||
|
printf "$Yellow$serverdir: $Bwhite$j\n$Color_off"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
printf "$Yellow**$Red error:$Color_off can't find package ($1)\n"
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#------------------- clear cached packages directory --------------------
|
||||||
|
clear() {
|
||||||
|
rm -v $cachedpkgdir/*
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
add)
|
||||||
|
add $*
|
||||||
|
;;
|
||||||
|
down)
|
||||||
|
down $2
|
||||||
|
;;
|
||||||
|
unpack)
|
||||||
|
unpack $2
|
||||||
|
;;
|
||||||
|
del)
|
||||||
|
del $*
|
||||||
|
;;
|
||||||
|
list)
|
||||||
|
list $2
|
||||||
|
;;
|
||||||
|
query)
|
||||||
|
query
|
||||||
|
;;
|
||||||
|
help)
|
||||||
|
help
|
||||||
|
;;
|
||||||
|
sync)
|
||||||
|
sync
|
||||||
|
;;
|
||||||
|
search)
|
||||||
|
search $2
|
||||||
|
;;
|
||||||
|
clear)
|
||||||
|
clear
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
help
|
||||||
|
;;
|
||||||
|
esac
|
||||||
Executable
+174
@@ -0,0 +1,174 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
########## ##########
|
||||||
|
########## ##########
|
||||||
|
## ## ##
|
||||||
|
## ##
|
||||||
|
## ## - RC BOOT SCRIPTS MANAGER FOR SIMPLE LINUX
|
||||||
|
## ## - AUTHOR -- TOLA MIRONCENKO
|
||||||
|
## ##
|
||||||
|
## ##
|
||||||
|
## ##########
|
||||||
|
## ##########
|
||||||
|
|
||||||
|
#----- colors -------
|
||||||
|
Green='\033[0;32m'
|
||||||
|
Color_off='\033[0m'
|
||||||
|
Red='\033[0;31m'
|
||||||
|
Bred='\033[1;31m'
|
||||||
|
Yellow='\033[1;33m'
|
||||||
|
White='\033[0;37m'
|
||||||
|
Bwhite='\033[1;37m'
|
||||||
|
#--------------------
|
||||||
|
|
||||||
|
rootdir=/
|
||||||
|
|
||||||
|
#------------------------ add to boot function --------------
|
||||||
|
add() {
|
||||||
|
resultlink=$(cat /usr/share/rc/ordernumbers | grep $1)
|
||||||
|
if [ -f /etc/init.d/$1 ] && [ $resultlink ]; then
|
||||||
|
cd /etc/rc.d
|
||||||
|
ln -sv ../init.d/$1 "$resultlink" &> /dev/null
|
||||||
|
echo "added $1 to init."
|
||||||
|
else
|
||||||
|
help
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
#--------------------- del from boot function ---------------
|
||||||
|
del() {
|
||||||
|
filetoremove=$(find /etc/rc.d/ | grep $1 )
|
||||||
|
if [ $filetoremove ]; then
|
||||||
|
rm -v $filetoremove &> /dev/null
|
||||||
|
echo "removed $1 from init."
|
||||||
|
else
|
||||||
|
help
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
#---------------------- start daemon function ---------------
|
||||||
|
start() {
|
||||||
|
if [ -f /etc/init.d/$1 ]; then
|
||||||
|
/etc/init.d/$1 start
|
||||||
|
else
|
||||||
|
help
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
#---------------- stop daemon function ----------------------
|
||||||
|
stop() {
|
||||||
|
if [ -f /etc/init.d/$1 ]; then
|
||||||
|
/etc/init.d/$1 stop
|
||||||
|
else
|
||||||
|
help
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
#------------- restart daemon function ----------------------
|
||||||
|
restart() {
|
||||||
|
if [ -f /etc/init.d/$1 ]; then
|
||||||
|
/etc/init.d/$1 restart
|
||||||
|
else
|
||||||
|
help
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
#------------------ list services ---------------------------
|
||||||
|
list() {
|
||||||
|
ls --color $rootdir/etc/init.d
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
#------------------ list enabled services -------------------
|
||||||
|
bootlist() {
|
||||||
|
ls --color $rootdir/etc/rc.d
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
#------------------ service status --------------------------
|
||||||
|
status() {
|
||||||
|
if [[ "$1" == "" ]]; then
|
||||||
|
help
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
if [[ "$(ls /etc/init.d | grep $1)" == "" ]]; then
|
||||||
|
printf "$Yellow**$Bred error:$Color_off can't find service /etc/init.d/$1\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
printf "$Yellow**$Green $1$Color_off\n"
|
||||||
|
rcdservice=$(ls $rootdir/etc/rc.d | grep $1 2> /dev/null)
|
||||||
|
if [[ "$rcdservice" == "" ]]; then
|
||||||
|
printf "Loaded:$Yellow unloaded$Color_off (/etc/rc.d)\n"
|
||||||
|
else
|
||||||
|
printf "Loaded:$Green loaded$Color_off (/etc/rc.d/$rcdservice)\n"
|
||||||
|
fi
|
||||||
|
servicepid=$(ls $rootdir/var/run | grep $1)
|
||||||
|
if [[ "$servicepid" == "" ]]; then
|
||||||
|
printf "Active: deactive (${Yellow}deactive$Color_off)\n"
|
||||||
|
else
|
||||||
|
printf "Active: active (${Green}running$Color_off); pid (/var/run/$servicepid)\n"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
#-------------- print help function -------------------------
|
||||||
|
help() {
|
||||||
|
echo "
|
||||||
|
** rc usage:
|
||||||
|
rc add [init.d script name] - add service on boot
|
||||||
|
rc del [init.d script name] - delete service from boot
|
||||||
|
rc start [init.d script name] - start service
|
||||||
|
rc stop [init.d script name] - stop service
|
||||||
|
rc restart [init.d script name] - restart service
|
||||||
|
rc list - list all services
|
||||||
|
rc bootlist - list enabled services
|
||||||
|
rc status [init.d script name] - check service status
|
||||||
|
|
||||||
|
examples:
|
||||||
|
rc add httpd
|
||||||
|
rc del httpd
|
||||||
|
rc start httpd
|
||||||
|
rc stop httpd
|
||||||
|
rc restart httpd
|
||||||
|
rc list
|
||||||
|
rc bootlist
|
||||||
|
"
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
command="$1"
|
||||||
|
|
||||||
|
case ${command} in
|
||||||
|
add)
|
||||||
|
add $2 $3
|
||||||
|
;;
|
||||||
|
del)
|
||||||
|
del $2
|
||||||
|
;;
|
||||||
|
start)
|
||||||
|
start $2
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
stop $2
|
||||||
|
;;
|
||||||
|
restart)
|
||||||
|
restart $2
|
||||||
|
;;
|
||||||
|
list)
|
||||||
|
list
|
||||||
|
;;
|
||||||
|
bootlist)
|
||||||
|
bootlist
|
||||||
|
;;
|
||||||
|
status)
|
||||||
|
status $2
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
help
|
||||||
|
;;
|
||||||
|
esac
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
. /etc/init.d/colors.sh
|
. /etc/init.d/funcs/colors.sh
|
||||||
|
|
||||||
[ -z "$1" ] && printf "$URED** ERROR: should be called from udhcpc\n$RESET" && exit 1
|
[ -z "$1" ] && printf "$URED** ERROR: should be called from udhcpc\n$RESET" && exit 1
|
||||||
RESOLF_CONF="/etc/resolv.conf"
|
RESOLF_CONF="/etc/resolv.conf"
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#------------- grub rescue ---------------------------
|
||||||
|
grub_rescue() {
|
||||||
|
grub-mkrescue -o $build/simplelinux.iso $rootfspath &>> $fulllogfile
|
||||||
|
check $? "Build grub-rescue"
|
||||||
|
cp -v $build/simplelinux.iso $out/ &>> $fulllogfile
|
||||||
|
}
|
||||||
|
#-----------------------------------------------------
|
||||||
|
|
||||||
|
#------------------ rootfs archive -------------------
|
||||||
|
rootfs_archive() {
|
||||||
|
cd $rootfspath
|
||||||
|
tar -czvf $out/simplelinux-$version-rootfs.tar.gz . &>> $fulllogfile
|
||||||
|
check $? "Build rootfs archive"
|
||||||
|
}
|
||||||
|
#-----------------------------------------------------
|
||||||
+39
-152
@@ -22,48 +22,23 @@ version=0.0.1 # script version
|
|||||||
#--- import funcs ----
|
#--- import funcs ----
|
||||||
. ./scripts/funcs.sh
|
. ./scripts/funcs.sh
|
||||||
#---------------------
|
#---------------------
|
||||||
|
#----- import config variables ----------
|
||||||
#------------ config ------------------
|
. ./scripts/config.sh
|
||||||
root=$(pwd) # root build directory
|
#----------------------------------------
|
||||||
disk="sdz" # disk to write install image
|
|
||||||
distro_name="Simple" # distro name
|
|
||||||
distro_desc="Simple linux distro" # distro desctiption
|
|
||||||
distro_codename="zero_zero_one" # distro codename
|
|
||||||
hyperv_support="false" # hyperv support for kernel image
|
|
||||||
out=$root/out # output directory
|
|
||||||
build=$root/build # build directory
|
|
||||||
sourcesfilename=sources.txt # sources file for downloading
|
|
||||||
initramfsfile=$root/initramfs/initramfs.txt # file to created directories for initramfs
|
|
||||||
initramfspath=$build/initramfs # initramfs build directory
|
|
||||||
rootfsfile=$root/rootfs/rootfs.txt # file to created directories for rootfs
|
|
||||||
rootfspath=$build/rootfs # rootfs build directory
|
|
||||||
fulllogfile=$root/.log/fulllog.log # file for full build logs
|
|
||||||
makeflags=-j16 # makeflags
|
|
||||||
#--------------------------------------
|
|
||||||
|
|
||||||
#----- import busybox build funcs ---
|
#----- import busybox build funcs ---
|
||||||
. ./scripts/busybox.sh
|
. ./scripts/busybox.sh
|
||||||
#------------------------------------
|
#------------------------------------
|
||||||
|
|
||||||
#-------- check root ------------------
|
#-------- check root ------------------
|
||||||
if [ $(id -u) -ne 0 ]; then
|
check_root
|
||||||
printf "$URED** You are not root\n$RESET"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
#--------------------------------------
|
#--------------------------------------
|
||||||
|
|
||||||
mkdir $out &>> $fulllogfile
|
mkdir $out &>> $fulllogfile
|
||||||
mkdir $root/.log &>> $fulllogfile
|
mkdir $root/.log &>> $fulllogfile
|
||||||
|
|
||||||
#------------ Download needed sources from sources.txt ------------------
|
#--------- import Download sources funcs ------
|
||||||
download_sources() {
|
. ./scripts/download.sh
|
||||||
printf "$UGREEN** Downloading sources\n$RESET"
|
#----------------------------------------------
|
||||||
cat $sourcesfilename
|
|
||||||
if [ ! -d downloads ]; then mkdir downloads; fi
|
|
||||||
wget --input-file=$sourcesfilename --continue --directory-prefix=$root/downloads
|
|
||||||
check $? "Download sources"
|
|
||||||
}
|
|
||||||
#------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#--------------- Building Linux Kernel ---------------------
|
#--------------- Building Linux Kernel ---------------------
|
||||||
kernel() {
|
kernel() {
|
||||||
@@ -103,88 +78,9 @@ kernel_modules() {
|
|||||||
} # kernel_modules
|
} # kernel_modules
|
||||||
#-----------------------------------------------------------
|
#-----------------------------------------------------------
|
||||||
|
|
||||||
#------------ glibc ----------------------------------------
|
#-------- import build glibc funcs ------------
|
||||||
glibc() {
|
. ./scripts/glibc.sh
|
||||||
printf "$UGREEN** Building glibc\n$RESET"
|
#----------------------------------------------
|
||||||
mkdir -p $build/glibc &>> $fulllogfile
|
|
||||||
cd $build/glibc
|
|
||||||
tar -xvf $root/downloads/glibc-2.39.tar.xz &>> $fulllogfile
|
|
||||||
check $? "Extract glibc"
|
|
||||||
cd glibc-2.39
|
|
||||||
mkdir build
|
|
||||||
cd build
|
|
||||||
echo "rootsbindir=/usr/bin" > configparms
|
|
||||||
../configure \
|
|
||||||
--prefix=/usr \
|
|
||||||
--disable-werror \
|
|
||||||
--enable-kernel=4.19 \
|
|
||||||
--enable-stack-protector=strong \
|
|
||||||
--disable-nscd \
|
|
||||||
libc_cv_slibdir=/usr/lib &>> $fulllogfile
|
|
||||||
check $? "Configure glibc"
|
|
||||||
make $makeflags &>> $fulllogfile
|
|
||||||
check $? "Build glibc"
|
|
||||||
make DESTDIR=$rootfspath install &>> $fulllogfile
|
|
||||||
check $? "Install glibc to rootfs"
|
|
||||||
cd $rootfspath
|
|
||||||
find -name \*.a -delete &>> $fulllogfile
|
|
||||||
strip --strip-unneeded $rootfspath/usr/lib/* $rootfspath/usr/bin/* &>> $fulllogfile
|
|
||||||
chroot $rootfspath /bin/sh -c "mkdir -p /usr/lib/locale;localedef -i C -f UTF-8 C.UTF-8;localedef -i en_US -f UTF-8 en_US.UTF-8;localedef -i ru_RU -f UTF-8 ru_RU-UTF-8;"
|
|
||||||
cd $root
|
|
||||||
check $? "Build and install glibc"
|
|
||||||
}
|
|
||||||
#-----------------------------------------------------------
|
|
||||||
|
|
||||||
# #------------------ Building busybox for initramfs ----------------
|
|
||||||
# busybox_initramfs() {
|
|
||||||
# printf "$UGREEN** Building busybox for initramfs\n$RESET"
|
|
||||||
# rm -r $build/busybox &>> $fulllogfile
|
|
||||||
# mkdir -p $build/busybox
|
|
||||||
# cd $build/busybox
|
|
||||||
# tar -xjf $root/downloads/busybox-1.36.1.tar.bz2
|
|
||||||
# check $? "Extract busybox"
|
|
||||||
# cd busybox-1.36.1
|
|
||||||
# cp $root/busybox/busybox-initramfs-config .config
|
|
||||||
# export PATH=$PATH:/opt/toolchains/x86_64-buildroot-linux-uclibc-gcc/bin
|
|
||||||
# printf "$UGREEN** Configuring busybox\n$RESET"
|
|
||||||
# make CROSS_COMPILE=x86_64-buildroot-linux-uclibc- oldconfig &> $fulllogfile
|
|
||||||
# check $? "Configure busybox all logs in .log"
|
|
||||||
# printf "$UGREEN** Building busybox\n$RESET"
|
|
||||||
# make CROSS_COMPILE=x86_64-buildroot-linux-uclibc- $makeflags &> $fulllogfile
|
|
||||||
# check $? "Build busybox all logs in .log"
|
|
||||||
# }
|
|
||||||
# # #------------------------------------------------------------------
|
|
||||||
|
|
||||||
# # #----------- Building busybox for rootfs ----------
|
|
||||||
# busybox_rootfs() {
|
|
||||||
# printf "$UGREEN** Building busybox for rootfs\n$RESET"
|
|
||||||
# rm -rv $build/busybox &>> $fulllogfile
|
|
||||||
# mkdir -v $build/busybox &>> $fulllogfile
|
|
||||||
# cd $build/busybox
|
|
||||||
# tar -xvjf $root/downloads/busybox-1.36.1.tar.bz2 &>> $fulllogfile
|
|
||||||
# cd busybox-1.36.1
|
|
||||||
# cp -v $root/busybox/busybox-rootfs-config .config &>> $fulllogfile
|
|
||||||
# printf "$UGREEN** Configuring busybox\n$RESET"
|
|
||||||
# make oldconfig &>> $fulllogfile
|
|
||||||
# check $? "Configure busybox all logs in .log"
|
|
||||||
# printf "$UGREEN** Building busybox\n$RESET"
|
|
||||||
# make $makeflags &>> $fulllogfile
|
|
||||||
# check $? "Build busybox all logs in .log"
|
|
||||||
# }
|
|
||||||
# #--------------------------------------------------
|
|
||||||
|
|
||||||
# #------------------ Building busybox ------------------------------
|
|
||||||
# busybox() {
|
|
||||||
# case "$1" in
|
|
||||||
# initramfs)
|
|
||||||
# busybox_initramfs
|
|
||||||
# ;;
|
|
||||||
# rootfs)
|
|
||||||
# busybox_rootfs
|
|
||||||
# ;;
|
|
||||||
# esac
|
|
||||||
# }
|
|
||||||
#------------------------------------------------------------------
|
|
||||||
|
|
||||||
#------------------ Building initramfs.img ------------------------
|
#------------------ Building initramfs.img ------------------------
|
||||||
initramfs() {
|
initramfs() {
|
||||||
@@ -244,9 +140,9 @@ rootfs() {
|
|||||||
glibc
|
glibc
|
||||||
kernel
|
kernel
|
||||||
cp -v $root/build/kernel/linux-6.7.4/arch/x86/boot/bzImage $rootfspath/boot/vmlinuz-linux &>> $fulllogfile
|
cp -v $root/build/kernel/linux-6.7.4/arch/x86/boot/bzImage $rootfspath/boot/vmlinuz-linux &>> $fulllogfile
|
||||||
kernel_modules &>> $fulllogfile
|
kernel_modules
|
||||||
initramfs
|
initramfs
|
||||||
cp -v $root/build/initramfs.img $rootfspath/boot/
|
cp -v $root/build/initramfs.img $rootfspath/boot/ &>> $fulllogfile
|
||||||
|
|
||||||
chmod 640 $rootfspath/etc/shadow $rootfspath/etc/inittab
|
chmod 640 $rootfspath/etc/shadow $rootfspath/etc/inittab
|
||||||
chmod 755 $rootfspath/etc/init.d/* $rootfspath/usr/share/udhcpc/default.script
|
chmod 755 $rootfspath/etc/init.d/* $rootfspath/usr/share/udhcpc/default.script
|
||||||
@@ -256,45 +152,36 @@ rootfs() {
|
|||||||
} # rootfs
|
} # rootfs
|
||||||
#--------------------------------------------------
|
#--------------------------------------------------
|
||||||
|
|
||||||
#---------- Cleaning build and out directory ---------
|
#----------- import cleaning funcs -------------
|
||||||
clean() {
|
. ./scripts/clean.sh
|
||||||
printf "$UGREEN** Cleaning build and out directories\n$RESET"
|
#-----------------------------------------------
|
||||||
rm -rv $root/.log/* &>> $fulllogfile
|
#-------- import build artifacts funcs ---------
|
||||||
mkdir -p $root/.log
|
. ./scripts/artifacts.sh
|
||||||
rm -rv $out &>> $fulllogfile
|
#-----------------------------------------------
|
||||||
mkdir -p $out
|
|
||||||
rm -rv $build &>> $fulllogfile
|
|
||||||
mkdir -p $build
|
|
||||||
printf "$UGREEN** SUCCESS: Cleaning build and out directories\n$RESET"
|
|
||||||
} # clean
|
|
||||||
#-----------------------------------------------------
|
|
||||||
|
|
||||||
#------------- grub rescue ---------------------------
|
|
||||||
grub_rescue() {
|
|
||||||
grub-mkrescue -o $build/simplelinux.iso $rootfspath &>> $fulllogfile
|
|
||||||
check $? "Build grub-rescue"
|
|
||||||
cp -v $build/simplelinux.iso $out/ &>> $fulllogfile
|
|
||||||
}
|
|
||||||
#-----------------------------------------------------
|
|
||||||
|
|
||||||
#------------------ rootfs archive -------------------
|
|
||||||
rootfs_archive() {
|
|
||||||
cd $rootfspath
|
|
||||||
tar -czvf $out/simplelinux-$version-rootfs.tar.gz . &>> $fulllogfile
|
|
||||||
check $? "Build rootfs archive"
|
|
||||||
}
|
|
||||||
#-----------------------------------------------------
|
|
||||||
|
|
||||||
if [ "$1" = "clean" ]; then
|
if [ "$1" = "clean" ]; then
|
||||||
clean
|
clean
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
clean
|
case "$1" in
|
||||||
download_sources
|
clean)
|
||||||
# kernel
|
clean
|
||||||
# kernel_modules
|
;;
|
||||||
# initramfs
|
build)
|
||||||
rootfs
|
clean
|
||||||
grub_rescue
|
download_sources
|
||||||
rootfs_archive
|
rootfs
|
||||||
|
grub_rescue
|
||||||
|
rootfs_archive
|
||||||
|
;;
|
||||||
|
download)
|
||||||
|
download_sources
|
||||||
|
;;
|
||||||
|
rootfs)
|
||||||
|
rootfs
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
printf "$UYELLOW** $0 script using: $0 {clean|build|download|rootfs}\n$RESET"
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#---------- Cleaning build and out directory ---------
|
||||||
|
clean() {
|
||||||
|
printf "$UGREEN** Cleaning build and out directories\n$RESET"
|
||||||
|
rm -rv $root/.log/* &>> $fulllogfile
|
||||||
|
mkdir -p $root/.log
|
||||||
|
rm -rv $out &>> $fulllogfile
|
||||||
|
mkdir -p $out
|
||||||
|
rm -rv $build &>> $fulllogfile
|
||||||
|
mkdir -p $build
|
||||||
|
printf "$UGREEN** SUCCESS: Cleaning build and out directories\n$RESET"
|
||||||
|
} # clean
|
||||||
|
#-----------------------------------------------------
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#------------ config ------------------
|
||||||
|
root=$(pwd) # root build directory
|
||||||
|
disk="sdz" # disk to write install image
|
||||||
|
distro_name="Simple" # distro name
|
||||||
|
distro_desc="Simple linux distro" # distro desctiption
|
||||||
|
distro_codename="zero_zero_one" # distro codename
|
||||||
|
hyperv_support="false" # hyperv support for kernel image
|
||||||
|
out=$root/out # output directory
|
||||||
|
build=$root/build # build directory
|
||||||
|
sourcesfilename=sources.txt # sources file for downloading
|
||||||
|
initramfsfile=$root/initramfs/initramfs.txt # file to created directories for initramfs
|
||||||
|
initramfspath=$build/initramfs # initramfs build directory
|
||||||
|
rootfsfile=$root/rootfs/rootfs.txt # file to created directories for rootfs
|
||||||
|
rootfspath=$build/rootfs # rootfs build directory
|
||||||
|
fulllogfile=$root/.log/fulllog.log # file for full build logs
|
||||||
|
makeflags=-j16 # makeflags
|
||||||
|
#--------------------------------------
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#------------ Download needed sources from sources.txt ------------------
|
||||||
|
download_sources() {
|
||||||
|
printf "$UGREEN** Downloading sources\n$RESET"
|
||||||
|
cat $sourcesfilename
|
||||||
|
if [ ! -d downloads ]; then mkdir downloads; fi
|
||||||
|
wget --input-file=$sourcesfilename --continue --directory-prefix=$root/downloads
|
||||||
|
check $? "Download sources"
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------------------
|
||||||
+10
-1
@@ -12,4 +12,13 @@ check() {
|
|||||||
fi
|
fi
|
||||||
printf "$UGREEN** SUCCESS: $2\n$RESET"
|
printf "$UGREEN** SUCCESS: $2\n$RESET"
|
||||||
}
|
}
|
||||||
#-------------------------------------------
|
#-------------------------------------------
|
||||||
|
|
||||||
|
#------- Check root func -------------------
|
||||||
|
check_root() {
|
||||||
|
if [ $(id -u) -ne 0 ]; then
|
||||||
|
printf "$URED** You are not root\n$RESET"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
#-------------------------------------------
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#------------ glibc ----------------------------------------
|
||||||
|
glibc() {
|
||||||
|
printf "$UGREEN** Building glibc\n$RESET"
|
||||||
|
mkdir -p $build/glibc &>> $fulllogfile
|
||||||
|
cd $build/glibc
|
||||||
|
tar -xvf $root/downloads/glibc-2.39.tar.xz &>> $fulllogfile
|
||||||
|
check $? "Extract glibc"
|
||||||
|
cd glibc-2.39
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
echo "rootsbindir=/usr/bin" > configparms
|
||||||
|
../configure \
|
||||||
|
--prefix=/usr \
|
||||||
|
--disable-werror \
|
||||||
|
--enable-kernel=4.19 \
|
||||||
|
--enable-stack-protector=strong \
|
||||||
|
--disable-nscd \
|
||||||
|
libc_cv_slibdir=/usr/lib &>> $fulllogfile
|
||||||
|
check $? "Configure glibc"
|
||||||
|
make $makeflags &>> $fulllogfile
|
||||||
|
check $? "Build glibc"
|
||||||
|
make DESTDIR=$rootfspath install &>> $fulllogfile
|
||||||
|
check $? "Install glibc to rootfs"
|
||||||
|
cd $rootfspath
|
||||||
|
find -name \*.a -delete &>> $fulllogfile
|
||||||
|
strip --strip-unneeded $rootfspath/usr/lib/* $rootfspath/usr/bin/* &>> $fulllogfile
|
||||||
|
chroot $rootfspath /bin/sh -c "mkdir -p /usr/lib/locale;localedef -i C -f UTF-8 C.UTF-8;localedef -i en_US -f UTF-8 en_US.UTF-8;localedef -i ru_RU -f UTF-8 ru_RU-UTF-8;"
|
||||||
|
cd $root
|
||||||
|
check $? "Build and install glibc"
|
||||||
|
}
|
||||||
|
#-----------------------------------------------------------
|
||||||
Reference in new issue
Block a user