refs #905: Improves installer
- Add function for deploying scripts in chroot - Install selected components in YAD dialog - Adds calamares packages module to the workflow to install vim and git - Deploy component installer to /opengnsys-installer/component-installer.sh in final system - Injects modules configs in /opengnsys-installer in the end system. - Creates ogadmin group in end system tor created user - template name changed to ogserver -user-story-905
parent
ac57866cd1
commit
05886eaa2e
37
builder.sh
37
builder.sh
|
@ -13,19 +13,20 @@ CLEAN_CHROOT=${CLEAN_CHROOT:-1}
|
|||
OUTPUT_DIR=/media/sf_Downloads/
|
||||
IMAGE_DIR=$DIR/image
|
||||
DEBOOT_STRAP_URL=http://mirror.raiolanetworks.com/ubuntu/
|
||||
SUDO_PASSWD=${SUDO_PASSWD:-$(cat $PASSWD_FILE)}
|
||||
|
||||
|
||||
export PASSWD_FILE
|
||||
|
||||
## FUNCIONES
|
||||
function exec_as_sudo () {
|
||||
cat $PASSWD_FILE | sudo -S $@
|
||||
cat $PASSWD_FILE | sudo -S "$@"
|
||||
}
|
||||
|
||||
function exec_as_sudo_in_chroot () {
|
||||
local CHROOT=$1
|
||||
shift
|
||||
exec_as_sudo chroot $CHROOT $@
|
||||
exec_as_sudo chroot $CHROOT "$@"
|
||||
}
|
||||
|
||||
function umount_in_chroot() {
|
||||
|
@ -53,6 +54,15 @@ function umount_in_host() {
|
|||
return 0
|
||||
}
|
||||
|
||||
function deploy_script_in_chroot() {
|
||||
local CHROOT=$1
|
||||
local SCRIPT=$2
|
||||
local DESTDIR=$3
|
||||
exec_as_sudo mkdir -p $CHROOT/$DESTDIR
|
||||
exec_as_sudo cp $SCRIPT $CHROOT/$DESTDIR
|
||||
exec_as_sudo chmod +x $CHROOT/$DESTDIR/$SCRIPT
|
||||
}
|
||||
|
||||
function deploy_installer() {
|
||||
exec_as_sudo mkdir -p $CHROOT_DIR/usr/local/bin
|
||||
exec_as_sudo cp openGnsys-installer.sh $CHROOT_DIR/usr/local/bin
|
||||
|
@ -78,7 +88,7 @@ then
|
|||
exec_as_sudo rm -rf $CHROOT_DIR
|
||||
exec_as_sudo rm -rf $UBUNTU_CHROOT_DIR
|
||||
fi
|
||||
exec_as_sudo rm -rf image
|
||||
exec_as_sudo rm -rf $DIR/image
|
||||
exec_as_sudo rm -f $OUTPUT_DIR/ubuntu-from-scratch.iso
|
||||
fi
|
||||
|
||||
|
@ -95,9 +105,10 @@ if [ $CLEAN_CHROOT -eq 1 ];
|
|||
then
|
||||
exec_as_sudo debootstrap --arch=amd64 --variant=$VARIANT $DIST $CHROOT_DIR $DEBOOT_STRAP_URL
|
||||
fi
|
||||
exec_as_sudo mkdir -p $CHROOT_DIR/etc/calamares/
|
||||
exec_as_sudo cp -r calamares/* $CHROOT_DIR/etc/calamares/
|
||||
deploy_installer
|
||||
exec_as_sudo mkdir -p $CHROOT_DIR/etc/calamares/modules/
|
||||
exec_as_sudo cp calamares/settings.conf $CHROOT_DIR/etc/calamares/
|
||||
exec_as_sudo cp calamares/modules/*.conf $CHROOT_DIR/etc/calamares/modules/
|
||||
deploy_script_in_chroot $CHROOT_DIR openGnsys-installer.sh /usr/local/bin/
|
||||
|
||||
# # Create mount points
|
||||
exec_as_sudo mount --bind /dev/ $CHROOT_DIR/dev
|
||||
|
@ -112,9 +123,9 @@ exec_as_sudo_in_chroot $CHROOT_DIR /chroot_setup.sh
|
|||
umount_in_host $CHROOT_DIR/dev
|
||||
umount_in_host $CHROOT_DIR/run
|
||||
|
||||
# Compress the chroot
|
||||
# Compress the chroot deploy
|
||||
mkdir -p $IMAGE_DIR
|
||||
exec_as_sudo mv $CHROOT_DIR/image $IMAGE_DIR/
|
||||
exec_as_sudo mv $CHROOT_DIR/image $DIR/
|
||||
|
||||
|
||||
# Create squashfs imagesudo
|
||||
|
@ -124,13 +135,16 @@ exec_as_sudo mksquashfs $CHROOT_DIR $IMAGE_DIR/casper/filesystem.squashfs \
|
|||
-comp xz -b 1M -Xdict-size 100% \
|
||||
-e "var/cache/apt/archives/*" -e "root/*" -e "root/.*" -e "tmp/*" -e "tmp/.*" -e "swapfile"
|
||||
|
||||
printf $(exec_as_sudo du -sx --block-size=1 chroot | cut -f1) | sudo tee image/casper/filesystem.size
|
||||
printf $(exec_as_sudo du -sx --block-size=1 $CHROOT_DIR | cut -f1) | sudo tee $IMAGE_DIR/casper/filesystem.size
|
||||
|
||||
# Deboot strap real Ubuntu image
|
||||
exec_as_sudo debootstrap --arch=amd64 --variant=minbase noble $UBUNTU_CHROOT_DIR $DEBOOT_STRAP_URL
|
||||
exec_as_sudo cp setup_chroot_ubuntu.sh $UBUNTU_CHROOT_DIR
|
||||
exec_as_sudo_in_chroot $UBUNTU_CHROOT_DIR chmod +x /setup_chroot_ubuntu.sh
|
||||
exec_as_sudo cp buildlib.sh $UBUNTU_CHROOT_DIR
|
||||
deploy_script_in_chroot $UBUNTU_CHROOT_DIR component-installer.sh /opengnsys-installer/
|
||||
exec_as_sudo cp pat.txt $UBUNTU_CHROOT_DIR/opengnsys-installer/
|
||||
|
||||
|
||||
# Setup the chroot for ubuntu
|
||||
exec_as_sudo mount --bind /dev/ $UBUNTU_CHROOT_DIR/dev
|
||||
|
@ -151,10 +165,7 @@ exec_as_sudo mksquashfs $UBUNTU_CHROOT_DIR $IMAGE_DIR/casper/filesystem.ubuntu.s
|
|||
-comp xz -b 1M -Xdict-size 100% \
|
||||
-e "var/cache/apt/archives/*" -e "root/*" -e "root/.*" -e "tmp/*" -e "tmp/.*" -e "swapfile"
|
||||
|
||||
|
||||
|
||||
# Create ISO image
|
||||
|
||||
cd $IMAGE_DIR && \
|
||||
exec_as_sudo xorriso \
|
||||
-as mkisofs \
|
||||
|
@ -190,4 +201,4 @@ exec_as_sudo xorriso \
|
|||
"/isolinux/bios.img=isolinux/bios.img" \
|
||||
"/isolinux/efiboot.img=isolinux/efiboot.img" \
|
||||
"."
|
||||
cd ..
|
||||
cd -
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
|
||||
update_db: true
|
||||
backend: apt
|
||||
operations:
|
||||
- install:
|
||||
- vim
|
||||
- git
|
|
@ -0,0 +1 @@
|
|||
../packages.conf
|
|
@ -3,7 +3,7 @@
|
|||
dontChroot: false
|
||||
verbose: true
|
||||
script:
|
||||
- /tmp/opengnsys-configs/component-installer.sh
|
||||
- /opengnsys-installer/component-installer.sh
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,10 +3,7 @@
|
|||
dontChroot: true
|
||||
verbose: true
|
||||
script:
|
||||
- mkdir -p ${ROOT}/tmp/opengnsys-configs
|
||||
- cp /tmp/opengnsys-installer-configs/* ${ROOT}/tmp/opengnsys-configs
|
||||
- cp /home/narenas/w/remote_fs/oginstaller/component-installer.sh ${ROOT}/tmp/opengnsys-configs
|
||||
- chmod 755 ${ROOT}/tmp/opengnsys-configs/component-installer.sh
|
||||
|
||||
|
||||
- mkdir -p ${ROOT}/opengnsys-installer
|
||||
- cp /tmp/opengnsys-installer-configs/* ${ROOT}/opengnsys-installer
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
---
|
||||
|
||||
dontChroot: false
|
||||
verbose: true
|
||||
script:
|
||||
- /tmp/opengnsys-configs/component-installer.sh
|
||||
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
../shell_chroot.conf
|
|
@ -1,12 +0,0 @@
|
|||
---
|
||||
|
||||
dontChroot: true
|
||||
verbose: true
|
||||
script:
|
||||
- mkdir -p ${ROOT}/tmp/opengnsys-configs
|
||||
- cp /tmp/opengnsys-installer-configs/* ${ROOT}/tmp/opengnsys-configs
|
||||
- cp /home/narenas/w/remote_fs/oginstaller/component-installer.sh ${ROOT}/tmp/opengnsys-configs
|
||||
- chmod 755 ${ROOT}/tmp/opengnsys-configs/component-installer.sh
|
||||
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
../shell_nonchroot.conf
|
|
@ -1,21 +1,18 @@
|
|||
defaultGroups:
|
||||
- name: users
|
||||
system: true
|
||||
- adm:
|
||||
system: true
|
||||
- cdrom:
|
||||
system: true
|
||||
- sudo:
|
||||
system: true
|
||||
- dip:
|
||||
system: true
|
||||
- plugdev:
|
||||
system: true
|
||||
- lxd:
|
||||
system: true
|
||||
- ogadmin:
|
||||
|
||||
|
||||
sudoersGroup: sudo
|
||||
setRootPassword: false
|
||||
sudoersGroup: ogadmin
|
||||
setRootPassword: true
|
||||
doReusePassword: true
|
||||
passwordRequirements:
|
||||
minLength: -1 # Password at least this many characters
|
||||
maxLength: -1 # Password at most this many characters
|
||||
|
@ -28,9 +25,10 @@ user:
|
|||
forbidden_names: [ root ]
|
||||
home_permissions: "0700"
|
||||
|
||||
|
||||
hostname:
|
||||
location: EtcFile
|
||||
writeHostsFile: true
|
||||
template: "derp-${cpu}"
|
||||
template: "ogServer"
|
||||
forbidden_names: [ localhost ]
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ sequence:
|
|||
- partition
|
||||
- mount
|
||||
- unpackfs
|
||||
- packages
|
||||
- machineid
|
||||
- locale
|
||||
- keyboard
|
||||
|
|
|
@ -3,17 +3,71 @@
|
|||
# Paso 1: Seleccionar los componentes
|
||||
# Los componentes a instalar se encuentran en el directorio /tmp/opengnsys-installer-configs
|
||||
|
||||
COMPONENTS="ogCore ogGui ogDhcp ogBoot"
|
||||
CONFIGS_DIR=/tmp/opengnsys-configs
|
||||
# Set configuration
|
||||
|
||||
COMPONENTS="ogCore ogGui ogDhcp ogBoot ogRepository"
|
||||
CONFIGS_DIR=/opengnsys-installer/
|
||||
PAT_FILE=/opengnsys-installer/pat.txt
|
||||
PAT=$(cat $PAT_FILE | tr -d '\n\r\t')
|
||||
|
||||
OPENGNSYS_BASE_URL="https://$PAT@ognproject.evlt.uma.es/gitea/opengnsys"
|
||||
|
||||
OGBOOT_REPO="$OPENGNSYS_BASE_URL/ogboot.git"
|
||||
OGCORE_REPO="$OPENGNSYS_BASE_URL/ogcore.git"
|
||||
OGDHCP_REPO="$OPENGNSYS_BASE_URL/ogdhcp.git"
|
||||
OGGUI_REPO="$OPENGNSYS_BASE_URL/oggui.git"
|
||||
OGREPOSITORY_REPO="$OPENGNSYS_BASE_URL/oggui.git"
|
||||
|
||||
export GIT_SSL_NO_VERIFY=1
|
||||
echo ======================================== > /etc/issue
|
||||
echo "OpenGnSys Installer" >> /etc/issue
|
||||
echo "Componentes instalados:" >> /etc/issue
|
||||
|
||||
|
||||
|
||||
for component in $COMPONENTS
|
||||
do
|
||||
config_file="config_${component}.json"
|
||||
if [ -f $CONFIGS_DIR/$config_file ]; then
|
||||
echo "Componente $component seleccionado, instalando configuración..."
|
||||
mkdir -p /opt/opengnsys/$component
|
||||
mkdir -p /opt/opengnsys/$component/installer
|
||||
component_dir=/opt/opengnsys/$component
|
||||
mkdir -p $component_dir/installer
|
||||
mkdir -p $component_dir/repo
|
||||
cp $CONFIGS_DIR/$config_file /opt/opengnsys/$component/installer/config.json
|
||||
|
||||
case $component in
|
||||
ogCore)
|
||||
echo "Instalando ogCore..."
|
||||
git clone "$OGCORE_REPO" "$component_dir/repo"
|
||||
echo - ogCore >> /etc/issue
|
||||
;;
|
||||
ogGui)
|
||||
echo "Instalando ogGui..."
|
||||
git clone "$OGGUI_REPO" "$component_dir/repo"
|
||||
echo - ogGui >> /etc/issue
|
||||
;;
|
||||
ogDhcp)
|
||||
echo "Instalando ogDhcp..."
|
||||
git clone "$OGDHCP_REPO" "$component_dir/repo"
|
||||
echo - ogDhcp >> /etc/issue
|
||||
;;
|
||||
ogBoot)
|
||||
echo "Instalando ogBoot..."
|
||||
git clone "$OGBOOT_REPO" "$component_dir/repo"
|
||||
echo - ogBoot >> /etc/issue
|
||||
;;
|
||||
ogRepository)
|
||||
echo "Instalando ogRepository..."
|
||||
git clone "$OGREPOSITORY_REPO" "$component_dir/repo"
|
||||
echo - ogRepository >> /etc/issue
|
||||
;;
|
||||
*)
|
||||
echo "Componente $component no reconocido"
|
||||
;;
|
||||
esac
|
||||
continue
|
||||
fi
|
||||
done
|
||||
|
||||
echo ======================================== >> /etc/issue
|
||||
rm -f $PAT_FILE
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
root
|
Loading…
Reference in New Issue