Commit 18a17416 by Bach Dániel

context: fixes #42

parent 08eb1894
description "cleanup.sh"
start on runlevel [2345]
stop on runlevel [!2345]
post-stop script
/etc/context/cleanup.sh
end script
#!/bin/bash
#rm -f /etc/ssh/ssh_host_*
if [ ! -f /run/context-cleanup ]; then
exit 0
fi
stop rsyslog
rm -fr /home/cloud/.bash_history /root/.bash_history /var/log/*
echo -e "auto lo\niface lo inet loopback\n" > /etc/network/interfaces
sed -i 's/^<volume user=.*//' /etc/security/pam_mount.conf.xml
rm -rf ~cloud/{.bash_history,.ssh/id_rsa}
rm -rf ~root/{.bash_history}
rm -rf /etc/ssh/ssh_host_*
......@@ -2,27 +2,32 @@
echo "En vagyok a $0 !"
if ! grep -qs -P '^\s*auto eth0' /etc/network/interfaces; then
arr=( $((echo 'ibase=16' ; ifconfig eth0 | awk '/HWaddr/ {print $5}' | tr ':a-z' '\nA-Z') | bc ) )
ipv4="${arr[2]}.${arr[3]}.${arr[4]}.${arr[5]}"
gw4="${arr[2]}.${arr[3]}.255.254"
ipv6="2001:738:2001:4031:${arr[3]}:${arr[4]}:${arr[5]}:0"
gw6="2001:738:2001:4031:${arr[3]}:255:254:0"
echo ok "$ipv4 $ipv6 $gw4 $gw6"
cat <<EOF >> /etc/network/interfaces
arr=( $((echo 'ibase=16' ; ifconfig eth0 | awk '/HWaddr/ {print $5}' | tr ':a-z' '\nA-Z') | bc ) )
ipv4="${arr[2]}.${arr[3]}.${arr[4]}.${arr[5]}"
gw4="${arr[2]}.${arr[3]}.255.254"
ipv6="2001:738:2001:4031:${arr[3]}:${arr[4]}:${arr[5]}:0"
gw6="2001:738:2001:4031:${arr[3]}:255:254:0"
echo ok "$ipv4 $ipv6 $gw4 $gw6"
/etc/init.d/network-manager stop
ifdown eth0 || ifconfig eth0 0 down
cat > /etc/network/interfaces << EOF
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address $ipv4
netmask 255.255.0.0
gateway $gw4
dns-nameservers 152.66.243.60
address $ipv4
netmask 255.255.0.0
gateway $gw4
dns-nameservers 152.66.243.60
iface eth0 inet6 static
address $ipv6
netmask 80
gateway $gw6
address $ipv6
netmask 80
gateway $gw6
EOF
ifconfig eth0 0;ifdown eth0;ifup eth0
fi
ifup eth0
......@@ -8,4 +8,5 @@ chmod 600 "$HOME/.ssh/id_rsa"
mkdir "$HOME/sshfs"
chown "$USER:$USER" -R "$HOME"
sed -i 's/^<volume user=.*//' /etc/security/pam_mount.conf.xml
sed -i "s/^\(<\/pam_mount>.*\)/<volume user=\"$USER\" fstype=\"fuse\" path=\"sshfs#${NEPTUN}@${SERVER}:home\" mountpoint=\"~\/sshfs\" options=\"nonempty,reconnect,StrictHostKeyChecking=no\" \/>\n\1/" /etc/security/pam_mount.conf.xml
......@@ -2,5 +2,7 @@
echo "En vagyok a $0 !"
echo "export NEPTUN=$NEPTUN" >> $HOME/.profile
if [ "$RECONTEXT" != "YES" ]; then
echo "export NEPTUN=$NEPTUN" >> $HOME/.profile
fi
......@@ -4,21 +4,26 @@ export BASEDIR=$(dirname $0)
export USER="cloud"
export HOME=$(awk -F: -v u=$USER '$1==u{print $6}' /etc/passwd)
mkdir -p "$BASEDIR/mnt"
cd "$BASEDIR"
mount -t iso9660 /dev/cdrom1 "$BASEDIR/mnt" 2> /dev/null
if [ $? -eq 0 -a -f "$BASEDIR/firstrun" -a -f "$BASEDIR/mnt/context.sh" ]; then
. "$BASEDIR/mnt/context.sh"
. "$BASEDIR/mnt/context.sh"
# hogy tudom kiexportalni ennel szebben ezeket a valtozokat?
eval `grep -o '^[a-zA-Z0-9]\+=' "$BASEDIR/mnt/context.sh" | while read x; do echo export ${x%=};done`
if [ "$RECONTEXT" != "YES" ]; then
rm "$BASEDIR/firstrun"
else
touch /run/context-cleanup
fi
run-parts "$BASEDIR/init.d"
for i in $BASEDIR/init.d/*; do
source $i
done
rm "$BASEDIR/firstrun"
else
echo "mar korabban lefutott!"
echo "mar korabban lefutott!"
fi
umount /dev/cdrom1 2>/dev/null
......
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 sign in to comment