mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-10013: Make Debian9 systemvmtemplates work with systemd
- Load the nf_conntrack_ipv6 module for IPv6 connection tracking on SSVM - Move systemd services to /etc and enable services after they have been installed - Disable most services by default and enable in cloud-early-config - Start services after enabling them using systemd - In addition remove /etc/init.d/cloud as this is no longer needed and done by systemd - Accept DOS/MBR as file format for ISO images as well Under Debian 7 the 'file' command would return: debian-9.1.0-amd64-netinst.iso: ISO 9660 CD-ROM filesystem data UDF filesystem data Under Debian 9 however it will return debian-9.1.0-amd64-netinst.iso: DOS/MBR boot sector This would make the HTTPTemplateDownloader in the Secondary Storage VM refuse the ISO as a valid template because it's not a correct format. Changes this behavior so that it accepts both. This allows us to use Debian 9 as a System VM template. Not sure though if enabling them is enough for systemd to still start them on first boot Signed-off-by: Wido den Hollander <wido@widodh.nl>
This commit is contained in:
parent
78bb74188d
commit
2aa70eecce
2
.gitignore
vendored
2
.gitignore
vendored
@ -97,3 +97,5 @@ systemvm/.pydevproject
|
||||
test/.pydevprojec
|
||||
plugins/hypervisors/kvm/.pydevproject
|
||||
scripts/.pydevproject
|
||||
*.qcow2
|
||||
*.raw
|
||||
|
||||
@ -1,155 +0,0 @@
|
||||
#!/bin/bash
|
||||
### BEGIN INIT INFO
|
||||
# Provides: cloud
|
||||
# Required-Start: $local_fs cloud-early-config
|
||||
# Required-Stop: $local_fs
|
||||
# Default-Start: 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Start up the CloudStack cloud service
|
||||
### END INIT INFO
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
#set -x
|
||||
|
||||
ENABLED=0
|
||||
[ -e /etc/default/cloud ] && . /etc/default/cloud
|
||||
|
||||
CMDLINE=$(cat /var/cache/cloud/cmdline)
|
||||
|
||||
if [ ! -z $CLOUD_DEBUG ];then
|
||||
LOG_FILE=/var/log/cloud/cloud.out
|
||||
else
|
||||
LOG_FILE=/dev/null
|
||||
fi
|
||||
|
||||
TYPE="router"
|
||||
for i in $CMDLINE
|
||||
do
|
||||
# search for foo=bar pattern and cut out foo
|
||||
FIRSTPATTERN=$(echo $i | cut -d= -f1)
|
||||
case $FIRSTPATTERN in
|
||||
type)
|
||||
TYPE=$(echo $i | cut -d= -f2)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Source function library.
|
||||
if [ -f /etc/init.d/functions ]
|
||||
then
|
||||
. /etc/init.d/functions
|
||||
fi
|
||||
|
||||
if [ -f ./lib/lsb/init-functions ]
|
||||
then
|
||||
. /lib/lsb/init-functions
|
||||
fi
|
||||
|
||||
_success() {
|
||||
if [ -f /etc/init.d/functions ]
|
||||
then
|
||||
success
|
||||
else
|
||||
echo "Success"
|
||||
fi
|
||||
}
|
||||
|
||||
_failure() {
|
||||
if [ -f /etc/init.d/functions ]
|
||||
then
|
||||
failure
|
||||
else
|
||||
echo "Failed"
|
||||
fi
|
||||
}
|
||||
RETVAL=$?
|
||||
CLOUDSTACK_HOME="/usr/local/cloud"
|
||||
if [ -f $CLOUDSTACK_HOME/systemvm/utils.sh ];
|
||||
then
|
||||
. $CLOUDSTACK_HOME/systemvm/utils.sh
|
||||
else
|
||||
_failure
|
||||
fi
|
||||
|
||||
# mkdir -p /var/log/vmops
|
||||
|
||||
start() {
|
||||
local pid=$(get_pids)
|
||||
if [ "$pid" != "" ]; then
|
||||
echo "CloudStack cloud sevice is already running, PID = $pid"
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo -n "Starting CloudStack cloud service (type=$TYPE) "
|
||||
if [ -f $CLOUDSTACK_HOME/systemvm/run.sh ];
|
||||
then
|
||||
if [ "$pid" == "" ]
|
||||
then
|
||||
(cd $CLOUDSTACK_HOME/systemvm; nohup ./run.sh > $LOG_FILE 2>&1 & )
|
||||
pid=$(get_pids)
|
||||
echo $pid > /var/run/cloud.pid
|
||||
fi
|
||||
_success
|
||||
else
|
||||
_failure
|
||||
fi
|
||||
echo
|
||||
echo 'start' > $CLOUDSTACK_HOME/systemvm/user_request
|
||||
}
|
||||
|
||||
stop() {
|
||||
local pid
|
||||
echo -n "Stopping CloudStack cloud service (type=$TYPE): "
|
||||
for pid in $(get_pids)
|
||||
do
|
||||
kill $pid
|
||||
done
|
||||
_success
|
||||
echo
|
||||
echo 'stop' > $CLOUDSTACK_HOME/systemvm/user_request
|
||||
}
|
||||
|
||||
status() {
|
||||
local pids=$(get_pids)
|
||||
if [ "$pids" == "" ]
|
||||
then
|
||||
echo "CloudStack cloud service is not running"
|
||||
return 1
|
||||
fi
|
||||
echo "CloudStack cloud service (type=$TYPE) is running: process id: $pids"
|
||||
return 0
|
||||
}
|
||||
|
||||
[ "$ENABLED" != 0 ] || exit 0
|
||||
|
||||
case "$1" in
|
||||
start) start
|
||||
;;
|
||||
stop) stop
|
||||
;;
|
||||
status) status
|
||||
;;
|
||||
restart) stop
|
||||
start
|
||||
;;
|
||||
*) echo "Usage: $0 {start|stop|status|restart}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
||||
@ -497,16 +497,6 @@ disable_rpfilter_domR() {
|
||||
echo "1" > /proc/sys/net/ipv4/conf/lo/rp_filter
|
||||
}
|
||||
|
||||
enable_svc() {
|
||||
local svc=$1
|
||||
local enabled=$2
|
||||
|
||||
log_it "Enable service ${svc} = $enabled"
|
||||
local cfg=/etc/default/${svc}
|
||||
[ -f $cfg ] && sed -i "s/ENABLED=.*$/ENABLED=$enabled/" $cfg && return
|
||||
}
|
||||
|
||||
|
||||
enable_irqbalance() {
|
||||
local enabled=$1
|
||||
local proc=0
|
||||
@ -803,6 +793,7 @@ setup_sshd(){
|
||||
[ -f /etc/ssh/sshd_config ] && sed -i -e "s/^[#]*ListenAddress.*$/ListenAddress $ip/" /etc/ssh/sshd_config
|
||||
sed -i "/3922/s/eth./$eth/" /etc/iptables/rules.v4
|
||||
sed -i "/3922/s/eth./$eth/" /etc/iptables/rules
|
||||
systemctl restart sshd
|
||||
}
|
||||
|
||||
|
||||
@ -935,11 +926,9 @@ setup_router() {
|
||||
echo "$ETH0_IP $NAME" >> /etc/hosts
|
||||
|
||||
|
||||
enable_svc dnsmasq 1
|
||||
enable_svc haproxy 1
|
||||
systemctl enable dnsmasq haproxy cloud-passwd-srvr
|
||||
systemctl restart dnsmasq haproxy cloud-passwd-srvr
|
||||
enable_irqbalance 1
|
||||
enable_svc cloud-passwd-srvr 1
|
||||
enable_svc cloud 0
|
||||
disable_rpfilter_domR
|
||||
enable_fwding 1
|
||||
enable_rpsrfs 1
|
||||
@ -1028,12 +1017,9 @@ EOF
|
||||
|
||||
setup_vpc_apache2
|
||||
|
||||
enable_svc dnsmasq 1
|
||||
enable_svc haproxy 1
|
||||
systemctl enable dnsmasq haproxy cloud-passwd-srvr
|
||||
enable_irqbalance 1
|
||||
enable_vpc_rpsrfs 1
|
||||
enable_svc cloud 0
|
||||
enable_svc cloud-passwd-srvr 1
|
||||
disable_rpfilter
|
||||
enable_fwding 1
|
||||
cp /etc/iptables/iptables-vpcrouter /etc/iptables/rules.v4
|
||||
@ -1061,6 +1047,8 @@ EOF
|
||||
fi
|
||||
load_modules
|
||||
|
||||
systemctl restart dnsmasq haproxy cloud-passwd-srvr
|
||||
|
||||
#setup hourly logrotate
|
||||
mv -n /etc/cron.daily/logrotate /etc/cron.hourly 2>&1
|
||||
|
||||
@ -1078,11 +1066,9 @@ setup_dhcpsrvr() {
|
||||
[ $ETH0_IP ] && echo "$ETH0_IP $NAME" >> /etc/hosts
|
||||
[ $ETH0_IP6 ] && echo "$ETH0_IP6 $NAME" >> /etc/hosts
|
||||
|
||||
enable_svc dnsmasq 1
|
||||
enable_svc haproxy 0
|
||||
systemctl enable dnsmasq cloud-passwd-srvr
|
||||
systemctl restart dnsmasq cloud-passwd-srvr
|
||||
enable_irqbalance 0
|
||||
enable_svc cloud-passwd-srvr 1
|
||||
enable_svc cloud 0
|
||||
enable_fwding 0
|
||||
systemctl disable nfs-common
|
||||
|
||||
@ -1156,7 +1142,7 @@ setup_ntp() {
|
||||
fi
|
||||
sed -i "0,/^server/s//$PATTERN\nserver/" $NTP_CONF_FILE
|
||||
done
|
||||
service ntp restart
|
||||
systemctl restart ntp
|
||||
else
|
||||
log_it "NTP configuration file not found"
|
||||
fi
|
||||
@ -1204,15 +1190,12 @@ Header always set Access-Control-Allow-Methods "POST, OPTIONS"
|
||||
Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token, x-signature, x-metadata, x-expires"
|
||||
CORS
|
||||
|
||||
service apache2 restart
|
||||
|
||||
disable_rpfilter
|
||||
enable_fwding 0
|
||||
enable_svc haproxy 0
|
||||
systemctl disable haproxy dnsmasq cloud-passwd-srvr
|
||||
systemctl enable cloud apache2
|
||||
systemctl restart cloud apache2
|
||||
enable_irqbalance 0
|
||||
enable_svc dnsmasq 0
|
||||
enable_svc cloud-passwd-srvr 0
|
||||
enable_svc cloud 1
|
||||
rm /etc/logrotate.d/cloud
|
||||
setup_ntp
|
||||
}
|
||||
@ -1233,13 +1216,10 @@ setup_console_proxy() {
|
||||
setup_sshd $ETH0_IP "eth0"
|
||||
fi
|
||||
|
||||
systemctl enable cloud
|
||||
disable_rpfilter
|
||||
enable_fwding 0
|
||||
enable_svc haproxy 0
|
||||
enable_irqbalance 0
|
||||
enable_svc dnsmasq 0
|
||||
enable_svc cloud-passwd-srvr 0
|
||||
enable_svc cloud 1
|
||||
systemctl disable nfs-common
|
||||
rm /etc/logrotate.d/cloud
|
||||
}
|
||||
@ -1263,11 +1243,7 @@ setup_elbvm() {
|
||||
fi
|
||||
|
||||
enable_fwding 0
|
||||
enable_svc haproxy 0
|
||||
enable_irqbalance 0
|
||||
enable_svc dnsmasq 0
|
||||
enable_svc cloud-passwd-srvr 0
|
||||
enable_svc cloud 0
|
||||
systemctl disable nfs-common
|
||||
systemctl disable portmap
|
||||
}
|
||||
@ -1286,11 +1262,8 @@ setup_ilbvm() {
|
||||
setup_sshd $ETH1_IP "eth1"
|
||||
|
||||
enable_fwding 0
|
||||
enable_svc haproxy 1
|
||||
systemctl enable haproxy
|
||||
enable_irqbalance 1
|
||||
enable_svc dnsmasq 0
|
||||
enable_svc cloud-passwd-srvr 0
|
||||
enable_svc cloud 0
|
||||
systemctl disable nfs-common
|
||||
systemctl disable portmap
|
||||
}
|
||||
|
||||
@ -35,6 +35,7 @@ function load_conntrack_modules() {
|
||||
|
||||
cat >> /etc/modules << EOF
|
||||
nf_conntrack_ipv4
|
||||
nf_conntrack_ipv6
|
||||
nf_conntrack
|
||||
nf_conntrack_ftp
|
||||
nf_nat_ftp
|
||||
|
||||
@ -36,10 +36,10 @@ function install_cloud_scripts() {
|
||||
rsync -av ./cloud_scripts/ /
|
||||
chmod +x /opt/cloud/bin/* \
|
||||
/root/{clearUsageRules.sh,reconfigLB.sh,monitorServices.py} \
|
||||
/etc/init.d/{cloud,cloud-early-config,cloud-passwd-srvr,postinit} \
|
||||
/etc/init.d/{cloud-early-config,cloud-passwd-srvr,postinit} \
|
||||
/etc/profile.d/cloud.sh
|
||||
|
||||
cat > /lib/systemd/system/cloud-early-config.service << EOF
|
||||
cat > /etc/systemd/system/cloud-early-config.service << EOF
|
||||
[Unit]
|
||||
Description=cloud-early-config: configure according to cmdline
|
||||
DefaultDependencies=no
|
||||
@ -57,7 +57,7 @@ TimeoutStartSec=5min
|
||||
|
||||
EOF
|
||||
|
||||
cat > /lib/systemd/system/cloud.service << EOF
|
||||
cat > /etc/systemd/system/cloud.service << EOF
|
||||
[Unit]
|
||||
Description=cloud: startup cloud service
|
||||
After=cloud-early-config.service network.target local-fs.target
|
||||
@ -66,14 +66,14 @@ After=cloud-early-config.service network.target local-fs.target
|
||||
WantedBy=multi-user.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
ExecStart=/etc/init.d/cloud start
|
||||
ExecStop=/etc/init.d/cloud stop
|
||||
RemainAfterExit=true
|
||||
TimeoutStartSec=5min
|
||||
Type=simple
|
||||
WorkingDirectory=/usr/local/cloud/systemvm
|
||||
ExecStart=/usr/local/cloud/systemvm/_run.sh
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
EOF
|
||||
|
||||
cat > /lib/systemd/system/cloud-passwd-srvr.service << EOF
|
||||
cat > /etc/systemd/system/cloud-passwd-srvr.service << EOF
|
||||
[Unit]
|
||||
Description=cloud-passwd-srvr: cloud password server
|
||||
After=network.target local-fs.target
|
||||
@ -89,7 +89,7 @@ RemainAfterExit=true
|
||||
TimeoutStartSec=5min
|
||||
EOF
|
||||
|
||||
cat > /lib/systemd/system/postinit.service << EOF
|
||||
cat > /etc/systemd/system/postinit.service << EOF
|
||||
[Unit]
|
||||
Description=cloud post-init service
|
||||
After=cloud-early-config.service network.target local-fs.target
|
||||
@ -143,6 +143,8 @@ function configure_services() {
|
||||
systemctl disable x11-common
|
||||
systemctl disable console-setup
|
||||
systemctl disable haproxy
|
||||
systemctl disable apache2
|
||||
systemctl disable dnsmasq
|
||||
|
||||
# Hyperv kvp daemon - 64bit only
|
||||
local arch=`dpkg --print-architecture`
|
||||
|
||||
@ -81,7 +81,7 @@ public class ImageStoreUtil {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (output.contains("ISO 9660") && isCorrectExtension(uripath, "iso")) {
|
||||
if ((output.startsWith("ISO 9660") || output.startsWith("DOS/MBR")) && isCorrectExtension(uripath, "iso")) {
|
||||
s_logger.debug("File at path " + path + " looks like an iso : " + output);
|
||||
return "";
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user