Commit 7a49a081 by KATOH Yasufumi Committed by Stéphane Graber

plamo: Improve template

* make simple * change default download site to http://ftp.ring.gr.jpSigned-off-by: 's avatarTAMUKI Shoichi <tamuki@linet.gr.jp> Signed-off-by: 's avatarKATOH Yasufumi <karma@jazz.email.ne.jp> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent 33ddfc2a
#!/bin/bash #!/bin/bash -eu
# #
# template script for generating Plamo Linux container for LXC # template script for generating Plamo Linux container for LXC
...@@ -28,35 +28,15 @@ ...@@ -28,35 +28,15 @@
# ref. https://github.com/Ponce/lxc-slackware/blob/master/lxc-slackware # ref. https://github.com/Ponce/lxc-slackware/blob/master/lxc-slackware
# lxc-ubuntu script # lxc-ubuntu script
set -eu
[ -r /etc/default/lxc ] && . /etc/default/lxc [ -r /etc/default/lxc ] && . /etc/default/lxc
LXC_TEMPLATE_CONFIG="@LXCTEMPLATECONFIG@" DLSCHEME=${DLSCHEME:-"http"}
MIRRORSRV=${MIRRORSRV:-"ftp.ring.gr.jp"}
DOWNLOAD_SCHEME=${DOWNLOAD_SCHEME:-"http"} MIRRORPATH=${MIRRORPATH:-"/pub/linux/Plamo"}
MIRRORSRV=${MIRRORSRV:-"ftp.ne.jp"} CATEGORIES=${CATEGORIES:-"00_base 01_minimum"}
MIRRORPATH=${MIRRORPATH:-"/Linux/distributions/plamolinux"} EXTRACTGRS=${EXTRACTGRS:-"Hamradio"}
CATEGORY[0]=${CATEGORY:-"00_base"} IGNOREPKGS=${IGNOREPKGS:-"grub kernel lilo linux_firmware microcode_ctl
IGNOREPKG[0]=${IGNOREPKGS:-"grub kernel lilo linux_firmware microcode_ctl"} cpufreqd cpufrequtils gpm cqrlog hamlib fldigi"}
CATEGORY[1]="01_minimum"
IGNOREPKG[1]="cpufreqd cpufrequtils gpm"
CATEGORY[2]="01_minimum/alsa.txz"
IGNOREPKG[2]=""
CATEGORY[3]="01_minimum/aspell.txz"
IGNOREPKG[3]=""
CATEGORY[4]="01_minimum/devel.txz"
IGNOREPKG[4]=""
CATEGORY[5]="01_minimum/gnupg_tls.txz"
IGNOREPKG[5]=""
CATEGORY[6]="01_minimum/network.txz"
IGNOREPKG[6]=""
CATEGORY[7]="01_minimum/nfs.txz"
IGNOREPKG[7]=""
CATEGORY[8]="01_minimum/tcl.txz"
IGNOREPKG[8]=""
CATEGORY_PATH=""
download_plamo() { download_plamo() {
# check the mini plamo was not already downloaded # check the mini plamo was not already downloaded
...@@ -67,32 +47,26 @@ download_plamo() { ...@@ -67,32 +47,26 @@ download_plamo() {
# download a mini plamo into a cache # download a mini plamo into a cache
echo "Downloading Plamo-$release minimal..." echo "Downloading Plamo-$release minimal..."
cd $ptcache cd $ptcache
for i in `seq 0 $((${#CATEGORY[@]} - 1))` ; do case $DLSCHEME in http) depth=2 ;; ftp) depth=3 ;; esac
CATEGORYPATH=${MIRRORPATH}/Plamo-${release}/${arch}/plamo/${CATEGORY[$i]} rej=${IGNOREPKGS%% *} ; [ -n "$rej" ] && rej="$rej-*"
WGETOPT="-nv -r -l1 -e robots=off -nd --no-parent -c --retr-symlinks -A .txz" for p in ${IGNOREPKGS#* } ; do rej="$rej,$p-*" ; done
EXCLUDE_OPT="" for i in $CATEGORIES ; do
if [ $DOWNLOAD_SCHEME = "http" ] ; then wget -nv -e robots=off -r -l $depth -nd -A .tgz,.txz -R $rej \
if [ -n "${IGNOREPKG[$i]}" ] ; then -I $MIRRORPATH/Plamo-$release/$arch/plamo/$i \
for p in ${IGNOREPKG[$i]} ; do -X $MIRRORPATH/Plamo-$release/$arch/plamo/$i/old \
EXCLUDE_OPT="${EXCLUDE_OPT} -R ${p}* " $DLSCHEME://$MIRRORSRV$MIRRORPATH/Plamo-$release/$arch/plamo/$i
done if [ $? -ne 0 ] ; then
fi echo "Failed to download the rootfs, aborting."
if ! wget ${WGETOPT} ${EXCLUDE_OPT} -X ${CATEGORY_PATH}/old http://${MIRRORSRV}${CATEGORYPATH} ; then return 1
echo "Failed to download the rootfs, aborting." fi
return 1 done
fi for i in $EXTRACTGRS ; do
elif [ $DOWNLOAD_SCHEME = "ftp" ] ; then wget -nv -e robots=off -r -l $depth -nd -A .tgz,.txz -R $rej \
if [ -n "${IGNOREPKG[$i]}" ] ; then -I $MIRRORPATH/Plamo-$release/$arch/contrib/$i \
for p in ${IGNOREPKG[$i]} ; do -X $MIRRORPATH/Plamo-$release/$arch/contrib/$i/old \
EXCLUDE_OPT="${EXCLUDE_OPT} -x ${p} " $DLSCHEME://$MIRRORSRV$MIRRORPATH/Plamo-$release/$arch/contrib/$i
done if [ $? -ne 0 ] ; then
fi echo "Failed to download the rootfs, aborting."
if ! lftp -c "open ${MIRRORSRV} && cd ${CATEGORYPATH} && mirror -i .txz -x old ${EXCLUDE_OPT} -r ." ; then
echo "Failed to download the rootfs, aborting."
return 1
fi
else
echo "Invalid DOWNLOAD_SCHEME value (can set http or ftp). "
return 1 return 1
fi fi
done done
...@@ -133,7 +107,7 @@ install_plamo() { ...@@ -133,7 +107,7 @@ install_plamo() {
echo "Installing packages to $rtcache..." echo "Installing packages to $rtcache..."
if [ ! -d $rtcache ] ; then if [ ! -d $rtcache ] ; then
mkdir -p $rtcache mkdir -p $rtcache
for p in `ls $dlcache` ; do for p in `ls -cr $dlcache/*.t?z` ; do
installpkg -root $rtcache -priority ADD $p installpkg -root $rtcache -priority ADD $p
done done
fi fi
...@@ -241,23 +215,24 @@ configure_plamo() { ...@@ -241,23 +215,24 @@ configure_plamo() {
} }
copy_configuration() { copy_configuration() {
ret=0
# Create the fstab (empty by default) cat <<- EOF >> $path/config || let ret++
touch $path/fstab
if ! cat <<- EOF >> $path/config ; then
lxc.utsname = $name lxc.utsname = $name
lxc.arch = $arch
lxc.mount = $path/fstab lxc.mount = $path/fstab
lxc.arch = $arch
EOF EOF
if [ -f "@LXCTEMPLATECONFIG@/plamo.common.conf" ] ; then
cat <<- "EOF" >> $path/config || let ret++
lxc.include = @LXCTEMPLATECONFIG@/plamo.common.conf
EOF
fi
# create the fstab (empty by default)
touch $path/fstab || let ret++
if [ $ret -ne 0 ] ; then
echo "Failed to add configuration." echo "Failed to add configuration."
return 1 return 1
fi fi
if [ -e "${LXC_TEMPLATE_CONFIG}/plamo.common.conf" ] ; then
echo "lxc.include = ${LXC_TEMPLATE_CONFIG}/plamo.common.conf" >> $path/config
fi
return 0 return 0
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment