Project

General

Profile

Download (2.71 KB) Statistics
| Branch: | Tag: | Revision:

fuss-fucc / utils / installFucc.sh @ master

1
#!/bin/bash
2

    
3
DATUM="$(date +%d-%b-%Y-ore-%H-%M)"
4

    
5
# ## Set the folder of clonezilla on the fuss-server if not corresponding to the actual standard ## #
6

    
7
clonezillaFolder="/srv/clonezilla"
8

    
9
tftpFolder="/srv/tftp"
10

    
11
####
12

    
13

    
14
# Check if this version of the "squash-file" is the same. If so do nothing.
15

    
16
checkThisSquash="$(md5sum filesystem.squashfs | awk '{print $1}')"
17
checkServerSquash="$(md5sum $tftpFolder/clonezilla/live/filesystem.squashfs | awk '{print $1}')"
18

    
19
if [ "$checkThisSquash" != "$checkServerSquash" ];then
20
    mv $tftpFolder/clonezilla/live/filesystem.squashfs $tftpFolder/clonezilla/live/filesystem.squashfs.BKP-$DATUM
21
    cp filesystem.squashfs $tftpFolder/clonezilla/live/
22
fi
23

    
24
# ######
25

    
26

    
27
if [ -e /root/.ssh/authorized_keys ];then
28
    cp /root/.ssh/authorized_keys /root/.ssh/authorized_keys.BKP-$DATUM
29
fi
30

    
31

    
32
# Check if the SSH key already exists, if so check if is in authorized-keys
33
if [ -e $clonezillaFolder/.ssh/id_rsa.pub ] ; then
34
	if ! grep $(cat $clonezillaFolder/.ssh/id_rsa.pub|cut -d ' ' -f 2) /root/.ssh/authorized_keys 2>&1 > /dev/null ; then
35
		echo 'command="if [[ \"$SSH_ORIGINAL_COMMAND\" =~ ^scp[[:space:]]-f ]] || [[ \"$SSH_ORIGINAL_COMMAND\" =~ ^add_client_principal ]] || [[ \"$SSH_ORIGINAL_COMMAND\" =~ rm[[:space:]]/root/ ]]; then $SSH_ORIGINAL_COMMAND; else echo \"Access Denied $SSH_ORIGINAL_COMMAND\"; fi"' $(cat $clonezillaFolder/.ssh/id_rsa.pub) >> /root/.ssh/authorized_keys
36
	fi
37
else
38
	# else, generate a new keypair and send it to root's authorized keys
39
	mkdir -p $clonezillaFolder/.ssh
40
	ssh-keygen -t rsa -N "" -f $clonezillaFolder/.ssh/id_rsa -C "root@fuss-fucc"
41
	echo 'command="if [[ \"$SSH_ORIGINAL_COMMAND\" =~ ^scp[[:space:]]-f ]] || [[ \"$SSH_ORIGINAL_COMMAND\" =~ ^add_client_principal ]] || [[ \"$SSH_ORIGINAL_COMMAND\" =~ rm[[:space:]]/root/ ]]; then $SSH_ORIGINAL_COMMAND; else echo \"Access Denied $SSH_ORIGINAL_COMMAND\"; fi"' $(cat $clonezillaFolder/.ssh/id_rsa.pub) >> /root/.ssh/authorized_keys
42
fi
43

    
44
ssh-keyscan -H proxy > $clonezillaFolder/.ssh/known_hosts 2>/dev/null
45

    
46
chown -R clonezilla. $clonezillaFolder/.ssh
47

    
48
chmod 400 $clonezillaFolder/.ssh/id_rsa*
49

    
50
cp -r clientScripts $clonezillaFolder
51

    
52
chmod -R 770 $clonezillaFolder/clientScripts
53

    
54

    
55
if [ -e $tftpFolder/pxelinux.cfg/default ];then
56
    mv $tftpFolder/pxelinux.cfg/default $tftpFolder/pxelinux.cfg/default.BKP-$DATUM
57
fi
58

    
59
cp default $tftpFolder/pxelinux.cfg
60

    
61
if [ -e $clonezillaFolder/computerList.txt ];then
62
    mv $clonezillaFolder/computerList.txt $clonezillaFolder/computerList.txt.BKP-$DATUM
63
fi
64

    
65
cp computerList.txt $clonezillaFolder
66

    
67
if [ -e $clonezillaFolder/script ];then
68
    mv $clonezillaFolder/script $clonezillaFolder/script.BKP-$DATUM
69
fi
70

    
71
cp script $clonezillaFolder
72

    
73
chmod 770 $clonezillaFolder/script
74

    
75
chown -R clonezilla. $clonezillaFolder/*
76

    
77
exit 0
(3-3/3)