Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
initramfs-with-mca
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
initramfs-with-mca
Commits
5876d0c3
Commit
5876d0c3
authored
Mar 16, 2023
by
Ophélie Gagnard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
generation: Clean the code.
parent
0d4ed329
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
115 deletions
+12
-115
generation/00env.sh
generation/00env.sh
+4
-4
generation/10install-dependencies.sh
generation/10install-dependencies.sh
+3
-1
generation/30generate-image.sh
generation/30generate-image.sh
+2
-108
generation/40upload-image.sh
generation/40upload-image.sh
+3
-2
No files found.
generation/00env.sh
View file @
5876d0c3
# This file is sourced by some other scripts in this directory
# This file is sourced by some other scripts in this directory
# get the root of the git repository
(requires git to be installed)
# get the root of the git repository
GIT_ROOT
=
`
git rev-parse
--show-toplevel
`
GIT_ROOT
=
$(
git rev-parse
--show-toplevel
)
PROJECT_DIR
=
$GIT_ROOT
PROJECT_DIR
=
"
$GIT_ROOT
"
### TO BE MODIFIED BY USERS ###
### TO BE MODIFIED BY USERS ###
KERNEL_VERSION
=
5.10.0-21
KERNEL_VERSION
=
5.10.0-21
...
@@ -13,7 +13,7 @@ PLG_PACKAGE_NAME=plugin-fluentbit-to-wendelin
...
@@ -13,7 +13,7 @@ PLG_PACKAGE_NAME=plugin-fluentbit-to-wendelin
MCA_VERSION
=
0.3.1
MCA_VERSION
=
0.3.1
FLB_VERSION
=
1.9.8
FLB_VERSION
=
1.9.8
PLG_VERSION
=
0.3.2
PLG_VERSION
=
0.3.2
CERT_NAME
=
db.crt
SIGNING_KEY_NAME
=
db.key
SIGNING_KEY_NAME
=
db.key
### DO NOT MODIFY ###
### DO NOT MODIFY ###
...
...
generation/10install-dependencies.sh
View file @
5876d0c3
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
set
-e
set
-e
# get the root of the git repository (requires git to be installed)
# get the root of the git repository (requires git to be installed)
GIT_ROOT
=
`
git rev-parse
--show-toplevel
`
GIT_ROOT
=
$(
git rev-parse
--show-toplevel
)
cd
"
$GIT_ROOT
"
/generation
cd
"
$GIT_ROOT
"
/generation
# define useful variables
# define useful variables
...
@@ -18,6 +18,8 @@ git config --local user.name "Ophelie Gagnard"
...
@@ -18,6 +18,8 @@ git config --local user.name "Ophelie Gagnard"
apt
-y
install
dracut-core dracut dracut-network sbsigntool pip
apt
-y
install
dracut-core dracut dracut-network sbsigntool pip
apt
-y
build-dep linux
apt
-y
build-dep linux
apt
-y
install
libncurses-dev
apt
-y
install
libncurses-dev
# the next line should be enabled when the following is merged and an egg containing the changes is released:
# https://lab.nexedi.com/nexedi/slapos.libnetworkcache/merge_requests/8
#pip install slapos.libnetworkcache
#pip install slapos.libnetworkcache
NC_BRANCH
=
cmdline-selection
NC_BRANCH
=
cmdline-selection
NC_DIR
=
"
${
NC_BRANCH
}
"
_slapos.libnetworkcache
NC_DIR
=
"
${
NC_BRANCH
}
"
_slapos.libnetworkcache
...
...
generation/30generate-image.sh
View file @
5876d0c3
#!/bin/bash
#!/bin/bash
## To run this script successfully, you MUST have sourced the target machine's specific environment file
## or have exported ALL the required variables. (See subdirectories of this directory.)
## This script assumes to be run by the root user (with /sbin in the path).
required_variables
=
"
CERT_NAME
SERVER_GROUP
"
for
variable
in
$required_variables
;
do
if
[
!
-v
"
$variable
"
]
;
then
echo
"ERROR:
$variable
is undefined, please export all required variables."
echo
"Required variables (and their value):"
for
v
in
$required_variables
;
do
echo
$v
=
${
!v
}
done
exit
1
fi
done
set
-e
set
-e
# get the root of the git repository (requires git to be installed)
# get the root of the git repository (requires git to be installed)
GIT_ROOT
=
`
git rev-parse
--show-toplevel
`
GIT_ROOT
=
$(
git rev-parse
--show-toplevel
)
cd
$GIT_ROOT
cd
"
$GIT_ROOT
"
# define useful variables
# define useful variables
source
generation/00env.sh
source
generation/00env.sh
get_partition_path
()
{
# Return the path of the desired partition.
# Exit and display an error if it finds 0 or several results.
#
# This function should be called ith exactly one argument: the desired partition type.
# Its behavior is undefined otherwise.
desired_partitions
=
$(
fdisk
-l
|
grep
"
$1
"
)
desired_partition_count
=
$(
echo
-e
"
$desired_partitions
"
|
wc
|
awk
'{print $1}'
)
if
[
-z
"
$desired_partitions
"
]
;
then
echo
-e
"No partition of type
$1
(shouldbe 1). Exiting."
exit
elif
[
"
$desired_partition_count
"
-ne
1
]
;
then
echo
-e
"
$desired_partition_count
partitions of type
$1
(should be 1). Exiting."
exit
else
echo
-e
"
$desired_partitions
"
|
awk
'{print $1}'
fi
}
get_partition_id
()
{
desired_partition_path
=
$(
get_partition_path
"
$1
"
)
echo
-e
"
$(
findmnt
-fn
-o
UUID
"
$desired_partition_path
"
)
"
}
get_default_interface
()
{
default_results
=
$(
ip route |
grep
default |
wc
|
awk
'{print $1}'
)
if
[
"
$default_results
"
-ne
1
]
;
then
echo
-e
"
$default_results
default result(s) (should be 1). Exiting."
exit
else
echo
-e
"
$(
ip route |
grep
default |
sed
's|.*dev \([^ ]*\).*|\1|g'
)
"
fi
}
get_default_router
()
{
default_results
=
$(
ip route |
grep
default |
wc
|
awk
'{print $1'
}
)
if
[
"
$default_results
"
-ne
1
]
;
then
echo
-e
"
$defaults_results
default result(s) (should be 1). Exiting."
exit
else
echo
-e
"
$(
ip route |
grep
default |
sed
's|.*via \([^ ]*\).*|\1|g'
)
"
fi
}
get_default_ip
()
{
default_interface
=
$(
get_default_interface
)
interface_results
=
$(
ip route |
grep
-v
default |
grep
"
$default_interface
"
|
wc
|
awk
'{print $1}'
)
if
[
"
$interface_results
"
-ne
1
]
;
then
echo
-e
"
$interface_results
results for
\"
${
default_interface
}
\"
(should be 1). Exiting."
exit
else
echo
-e
"
$(
ip route |
grep
-v
default |
grep
"
$default_interface
"
|
sed
's|.*src \([^ ]*\).*|\1|g'
)
"
fi
}
get_default_netmask
()
{
default_interface
=
$(
get_default_interface
)
interface_results
=
$(
ip route |
grep
-v
default |
grep
"
$default_interface
"
|
wc
|
awk
'{print $1}'
)
if
[
"
$interface_results
"
-ne
1
]
;
then
echo
-e
"
$interface_results
results for
\"
${
default_interface
}
\"
(should be 1). Exiting."
exit
else
echo
-e
"
$(
ip route |
grep
-v
default |
grep
"
$default_interface
"
|
sed
's|^\([^ ]*\).*|\1|g'
)
"
fi
}
int_to_generic_netmask
()
{
# get the mask size: the number right after the "/" (ex: <ipv4>/24 -> 24)
mask_length
=
$1
mask
=
""
for
i
in
{
0..3
}
;
do
if
[
${
mask_length
}
-ge
8
]
;
then
mask
=
${
mask
}
255
elif
[
${
mask_length
}
-eq
0
]
;
then
mask
=
${
mask
}
0
else
mask
=
${
mask
}$((
256
-
2
**(
8
-
${
mask_length
}))
)
fi
if
[
$i
-ne
3
]
;
then
mask
=
${
mask
}
.
fi
mask_length
=
$((
mask_length-8
))
done
echo
-e
"
${
mask
}
"
}
CERT_DIR
=
uefi-keys/public-certificates
CERT_DIR
=
uefi-keys/public-certificates
KEYS_DIR
=
uefi-keys/private-keys
KEYS_DIR
=
uefi-keys/private-keys
PUBLIC_CERT_DIR
=
${
PROJECT_DIR
}
/
${
CERT_DIR
}
/
${
SERVER_GROUP
}
PUBLIC_CERT_DIR
=
${
PROJECT_DIR
}
/
${
CERT_DIR
}
/
${
SERVER_GROUP
}
...
...
generation/40upload-image.sh
View file @
5876d0c3
...
@@ -3,15 +3,16 @@
...
@@ -3,15 +3,16 @@
set
-e
set
-e
# get the root of the git repository (requires git to be installed)
# get the root of the git repository (requires git to be installed)
GIT_ROOT
=
`
git rev-parse
--show-toplevel
`
GIT_ROOT
=
$(
git rev-parse
--show-toplevel
)
cd
$GIT_ROOT
cd
$GIT_ROOT
# define useful variables
# define useful variables
source
generation/00env.sh
source
generation/00env.sh
SERVER_GROUP
=
"
${
SERVER_GROUP
:-
generic
}
"
metadata_file
=
metadata.json
metadata_file
=
metadata.json
sha_list
=
installation/images-sha512.list
sha_list
=
installation/images-sha512.list
hash_comment
=
"#
self-compiled kernel, network autoconfig off + dummy ips, rd.neednet=1 LABEL=Root, metadata in shadir, no scan no
send"
hash_comment
=
"#
debian-signed Debian kernel, network autoconfig off + dummy ips, rd.neednet=1 LABEL=Root, metadata in shadir, scan and
send"
version_to_list
()
{
version_to_list
()
{
# take a version with no letters, and return a json list
# take a version with no letters, and return a json list
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment