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 #!/bin/bash
#rm -f /etc/ssh/ssh_host_* if [ ! -f /run/context-cleanup ]; then
exit 0
fi
stop rsyslog 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,15 +2,20 @@ ...@@ -2,15 +2,20 @@
echo "En vagyok a $0 !" 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 ) )
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]}"
ipv4="${arr[2]}.${arr[3]}.${arr[4]}.${arr[5]}" gw4="${arr[2]}.${arr[3]}.255.254"
gw4="${arr[2]}.${arr[3]}.255.254" ipv6="2001:738:2001:4031:${arr[3]}:${arr[4]}:${arr[5]}:0"
ipv6="2001:738:2001:4031:${arr[3]}:${arr[4]}:${arr[5]}:0" gw6="2001:738:2001:4031:${arr[3]}:255:254:0"
gw6="2001:738:2001:4031:${arr[3]}:255:254:0"
echo ok "$ipv4 $ipv6 $gw4 $gw6"
echo ok "$ipv4 $ipv6 $gw4 $gw6"
cat <<EOF >> /etc/network/interfaces /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 auto eth0
iface eth0 inet static iface eth0 inet static
address $ipv4 address $ipv4
...@@ -22,7 +27,7 @@ iface eth0 inet6 static ...@@ -22,7 +27,7 @@ iface eth0 inet6 static
netmask 80 netmask 80
gateway $gw6 gateway $gw6
EOF EOF
ifconfig eth0 0;ifdown eth0;ifup eth0
fi ifup eth0
...@@ -8,4 +8,5 @@ chmod 600 "$HOME/.ssh/id_rsa" ...@@ -8,4 +8,5 @@ chmod 600 "$HOME/.ssh/id_rsa"
mkdir "$HOME/sshfs" mkdir "$HOME/sshfs"
chown "$USER:$USER" -R "$HOME" 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 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 @@ ...@@ -2,5 +2,7 @@
echo "En vagyok a $0 !" echo "En vagyok a $0 !"
echo "export NEPTUN=$NEPTUN" >> $HOME/.profile if [ "$RECONTEXT" != "YES" ]; then
echo "export NEPTUN=$NEPTUN" >> $HOME/.profile
fi
...@@ -4,6 +4,7 @@ export BASEDIR=$(dirname $0) ...@@ -4,6 +4,7 @@ export BASEDIR=$(dirname $0)
export USER="cloud" export USER="cloud"
export HOME=$(awk -F: -v u=$USER '$1==u{print $6}' /etc/passwd) export HOME=$(awk -F: -v u=$USER '$1==u{print $6}' /etc/passwd)
mkdir -p "$BASEDIR/mnt"
cd "$BASEDIR" cd "$BASEDIR"
mount -t iso9660 /dev/cdrom1 "$BASEDIR/mnt" 2> /dev/null mount -t iso9660 /dev/cdrom1 "$BASEDIR/mnt" 2> /dev/null
...@@ -11,12 +12,16 @@ mount -t iso9660 /dev/cdrom1 "$BASEDIR/mnt" 2> /dev/null ...@@ -11,12 +12,16 @@ mount -t iso9660 /dev/cdrom1 "$BASEDIR/mnt" 2> /dev/null
if [ $? -eq 0 -a -f "$BASEDIR/firstrun" -a -f "$BASEDIR/mnt/context.sh" ]; then 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? if [ "$RECONTEXT" != "YES" ]; then
eval `grep -o '^[a-zA-Z0-9]\+=' "$BASEDIR/mnt/context.sh" | while read x; do echo export ${x%=};done` 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 else
echo "mar korabban lefutott!" echo "mar korabban lefutott!"
fi fi
......
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