Project

General

Profile

install-pi.sh

Alexie, 08/27/2018 04:23 PM

 
1
#!/bin/bash
2

    
3
################################################################################
4
# This script builds a Raspberry Pi image
5
#
6
# We heavily use:
7
# https://github.com/guysoft/CustomPiOS.git
8
################################################################################
9

    
10
################################################################################
11
# Configuration options
12
################################################################################
13

    
14
WEBSERVER="NGINX" # LIGHTTPD or NGINX
15
OPENZWAVE="YES" # YES or NO
16
KNX="YES" # YES or NO
17
RASPBIAN="stretch"
18
MNTDIR="/var/tmp/mnt"
19

    
20
################################################################################
21
# We need to be root, to do our magic with deb installation
22
################################################################################
23
if [ $(id -u) -ne 0 ]; then
24
  echo "Script must be run as root"
25
  exit 1
26
fi
27

    
28
echo ""
29

    
30
################################################################################
31
# Get own full script name
32
################################################################################
33

    
34
export MYSCRIPT=`realpath $0`
35
export MYDIR=`dirname $MYSCRIPT`
36

    
37
################################################################################
38
# Create our work directory
39
################################################################################
40

    
41
# Check if the directory already exist
42
if [ ! -d ~/install ]; then
43
  echo "INFO: Created '~/install' directory"
44
  mkdir ~/install
45
fi
46

    
47
if [ ! -d ~/install/pi-backup ]; then
48
  echo "INFO: Created '~/install/pi-backup' directory"
49
  mkdir ~/install/pi-backup
50
fi
51

    
52
################################################################################
53
# Install packages
54
################################################################################
55

    
56
if [ ! -f ~/install/.pi-package ]; then
57
  echo "INFO: Updating DEB database"
58
  apt-get -qq update
59
  echo "INFO: Installing packages (if not installed)"
60
  apt-get install -qq -y qemu qemu-system util-linux git git-core
61
  if [ $? -ne 0 ]; then
62
    echo "ERROR: FAILED to install qemu-system"
63
    exit 1
64
  fi
65
  touch ~/install/.pi-package
66
fi
67

    
68
################################################################################
69
# Download some Pi tools
70
################################################################################
71

    
72
cd ~/install
73
if [ ! -d CustomPiOS ]; then
74
  echo "### Installing and compiling CustomPiOS (Pi Tools)"
75
  git clone https://github.com/guysoft/CustomPiOS.git
76
fi
77

    
78
################################################################################
79
# Source our own file, otherwise get it from CustomPiOS
80
################################################################################
81

    
82
source $MYDIR/custompios-common.sh
83
if [ $? -ne 0 ]; then
84
  if [ ! ~/install/CustomPiOS/src/common.sh ]; then
85
    echo "ERROR: Cannot find '~/install/CustomPiOS/src/common.sh'"
86
    exit 1
87
  fi
88

    
89
  echo "INFO: Trying to use '~/install/CustomPiOS/src/common.sh'"
90
  cp ~/install/CustomPiOS/src/common.sh $MYDIR/custompios/common.sh
91
  if [ $? -ne 0 ]; then
92
    echo "ERROR: Cannot copy the '~/install/CustomPiOS/src/common.sh' file"
93
    exit 1
94
  fi
95

    
96
  source $MYDIR/custompios-common.sh
97
  if [ $? -ne 0 ]; then
98
    echo "ERROR: Cannot source '$MYDIR/custompios-common.sh'"
99
    exit 1
100
  fi
101
fi
102

    
103
################################################################################
104
# Mount the image and modify files
105
################################################################################
106

    
107
if [ ! -d "$MNTDIR" ]; then
108
  echo "INFO: Creating temporary mount directory '$MNTDIR'"
109
  mkdir -p "$MNTDIR"
110
fi
111

    
112
IMG=`ls -1 ~/????-??-??-*raspbian*$RASPBIAN*.img`
113
if [ ! -f $IMG ]; then
114
  echo "ERROR: There is an issue with the image file '$IMG'"
115
  exit 1
116
fi
117

    
118
if [ "$IMG" == "" ]; then
119
  echo "ERROR: The image IMG filename looks to be empty"
120
  exit 1
121
fi
122

    
123
if [ ! -f $IMG ]; then
124
  echo "ERROR: Can't find the image IMG '$IMG'"
125
  exit 1
126
fi
127

    
128

    
129
IMGSIZE=`stat --printf="%s" $IMG`
130
IMGSIZE=`expr $IMGSIZE / 1024 / 1024` 
131
echo "INFO: Size of IMG '$IMG' is "$IMGSIZE"MB"
132

    
133
# Need to resize it to 3GB for the lite image
134
# Expected to have enough space on the normal image
135
if [ $IMGSIZE -lt 3000 ]; then
136
  IMGADD=`expr 3000 - $IMGSIZE`
137
else
138
  IMGADD=0
139
fi
140

    
141
if [ $IMGADD -gt 0 ]; then
142
  echo "INFO: Increasing the image size with "$IMGADD"MB"
143
  qemu-img resize $IMG +$IMGADD\M
144
  if [ $? -ne 0 ]; then
145
    echo "ERROR: FAILED to resize Raspberry Pi image '$IMG' with "$IMGADD"MB"
146
    exit 1
147
  fi
148
fi
149

    
150
# Called from CustomPiOS common.sh
151
mount_image $IMG 2 $MNTDIR
152
if [ $? -ne 0 ]; then
153
  echo "ERROR: FAILED to mount the image '$IMG'"
154
  exit 1
155
fi
156

    
157
echo "INFO: Mounted the Raspberry Pi image file '$IMG' on '$MNTDIR'"
158

    
159
# Check if we patched it already, then skip this step
160
grep "\/dev\/sda1 " $MNTDIR/etc/fstab >/dev/null
161
if [ $? -eq 1 ]; then
162
  echo "INFO: Patching image"
163
  pushd "$MNTDIR"
164
    cp etc/ld.so.preload ~/install/pi-backup/
165
    cp etc/fstab ~/install/pi-backup/
166
    cp etc/init.d/resize2fs_once ~/install/pi-backup/
167
    cp etc/init/ssh.override ~/install/pi-backup/
168
    cp etc/fake-hwclock.data ~/install/pi-backup/
169
    cp etc/resolv.conf ~/install/pi-backup/
170

    
171
    fixLd
172
    sed -e '/PARTUUID/ s/^#*/#/' -i etc/fstab
173
    echo "/dev/sda1 /boot vfat    defaults          0       2" >> etc/fstab
174

    
175
    mkdir home/pi/install
176

    
177
    # Create a simple script to make the softlink and re-run the raspi-config
178
    # NOTE: use raspi-config and "Expand Filesystem"
179
    cat >home/pi/install/resize.sh << EOF
180
#!/bin/bash
181

    
182
PART_START="\$(sudo parted /dev/sda -ms unit s p |grep "^2" |cut -f2 -d: | cut -d "s" -f 1 | cut -d "s" -f 1)"
183
printf "d\n2\nn\np\n2\n\$PART_START\n\np\nw\n" | fdisk /dev/sda
184

    
185
EOF
186

    
187
    # Make script executable
188
    chmod a+x home/pi/install/resize.sh
189

    
190
    # Copy DEB files, if existing
191
    if [ -d ~/install/gambas3 ]; then
192
      cp -rp ~/install/gambas3 home/pi/install
193
    fi
194

    
195
    cat >home/pi/install/domotiga.sh << EOF
196
#!/bin/bash
197

    
198
  # Resize our root file-system first
199
  resize2fs /dev/sda2
200

    
201
  # Prevent lc warnings
202
  export LC_ALL="en_GB.UTF-8"
203

    
204
  #echo "INFO: Enable and start SSH"
205
  #update-rc.d ssh enable
206
  #invoke-rc.d ssh start
207

    
208
  # Add the Gambas3 repo if we don't have pre-build deb files
209
  if [ ! -d /home/pi/install/gambas3 ]; then
210
    echo "INFO: Adding Gambas3 repo from domotiga.nl"
211
    wget -O - https://domotiga.nl/apt/public.gpg.key | sudo apt-key add -
212
    su -c "echo 'deb https://domotiga.nl/apt/raspbian stretch main' >> /etc/apt/sources.list"
213
  fi
214

    
215
  echo "INFO: Update packages"
216
  apt-get update
217
  apt-get -y upgrade
218

    
219
  echo "INFO: Install Gambas3"
220
  if [ -d /home/pi/install/gambas3 ]; then
221
    echo "INFO: Install Gambas3 (pre-build DEB files)"
222
    cd /home/pi/install/gambas3
223

    
224
    # This will partially fail, because dependancies aren't met
225
    dpkg -i *.deb
226

    
227
    # Now solve dependancies and fix gambas3 installation
228
    apt-get -f -y install
229
  else
230
    echo "INFO: Install Gambas3 (domotiga.nl)"
231
    apt-get install -y gambas3
232
  fi
233

    
234
  echo "INFO: Automatic install MySQL and Git"
235
  echo "mysql-server mysql-server/root_password password domotiga" | debconf-set-selections
236
  echo "mysql-server mysql-server/root_password_again password domotiga" | debconf-set-selections
237
  apt-get install -y mysql-server git
238

    
239
  # Fix the memory usage and disable innodb automatically
240
  #echo "INFO: Disabling InnoDB in MySQL"
241
  #echo "# Disable InnoDB" >>/etc/mysql/my.cnf
242
  #echo "innodb=OFF" >>/etc/mysql/my.cnf
243
  #echo "default-storage-engine=MyISAM" >>/etc/mysql/my.cnf
244

    
245
  # Restart MySQL
246
  #/etc/init.d/mysql restart
247

    
248
  echo "INFO: Get and install DomotiGa software"
249
  cd /home/pi
250
  git clone --single-branch https://github.com/DomotiGa/DomotiGa.git domotiga
251
  rm -rf /home/pi/domotiga/.git
252
  chown -R pi:pi /home/pi/domotiga
253

    
254
  echo "INFO: Install startup script for DomotiGaServer3"
255
  cp /home/pi/domotiga/tools/domotigaserver3.debian /etc/init.d/domotigaserver3
256
  sed -i "s/USER=domo/USER=pi/" /etc/init.d/domotigaserver3
257
  update-rc.d domotigaserver3 defaults
258

    
259
  # add dialout to domo user - will hang livecd!
260
  #sed -i "s/dialout:x:20:/dialout:x:20:domo/" /etc/group
261

    
262
  echo "INFO: Importing example DomotiGa database"
263
  mysqladmin -u root -pdomotiga create domotiga
264
  mysql -u root -pdomotiga domotiga <domotiga/install/domotiga.sql
265

    
266
  if [ "$OPENZWAVE" == "YES" ]; then
267
    echo "INFO: Install required software for open-zwave library & wrapper"
268
    cd /home/pi/domotiga/wrappers/domozwave
269
    apt-get install -y libudev-dev libcurl4-gnutls-dev
270

    
271
    echo "INFO: Checkout the open-zwave library"
272
    git clone https://github.com/OpenZWave/open-zwave open-zwave
273
    rm -rf /home/pi/domotiga/wrappers/domozwave/open-zwave/.git
274

    
275
    chown -R pi:pi open-zwave
276

    
277
    echo "INFO: Compile open-zwave library"
278
    cd open-zwave
279
    make
280

    
281
    echo "INFO: The open-zwave library is compiled, lets link it to our domozwave library"
282
    cd /home/pi/domotiga/wrappers/domozwave
283
    make
284
    make install
285

    
286
    echo "INFO: Now remove the compiled open-zwave again, we don't need it"
287
    cd /home/pi/domotiga/wrappers/domozwave/open-zwave
288
    make clean
289
  fi
290

    
291
  if [ "$KNX" == "YES" ]; then
292
    echo "INFO: Install KNX/EIBD dependencies"
293
    apt-get install -y libxml2-dev liblua5.1-0-dev
294
    mkdir -p /home/pi/install/eibd
295
    cd /home/pi/install/eibd 
296
    wget --no-check-certificate https://www.auto.tuwien.ac.at/~mkoegler/pth/pthsem_2.0.8.tar.gz
297
    tar -zxvf pthsem_2.0.8.tar.gz
298
    cd pthsem-2.0.8
299
    ./configure
300
    sed -i "s/^CFLAGS = -g -O2/CFLAGS = -g -O2 -D_FORTIFY_SOURCE=0/" Makefile
301
    make
302
    make install
303
    ldconfig
304

    
305
    cd /home/pi/install/eibd
306
    wget http://www.auto.tuwien.ac.at/~mkoegler/eib/bcusdk_0.0.5.tar.gz
307
    tar xzvf bcusdk_0.0.5.tar.gz
308

    
309
    cat >usb.patch << EOS
310
--- bcusdk-0.0.5/eibd/usb/linux_usbfs.c.orig    2011-01-26 11:50:08.000000000 +0100
311
+++ bcusdk-0.0.5/eibd/usb/linux_usbfs.c    2011-08-25 22:57:29.000000000 +0200
312
@@ -52,7 +52,8 @@
313
     return 0;
314
 }
315

    
316
-int clock_gettime(clockid_t clk_id, struct timespec *tp)
317
+#define clock_gettime(A,B) xclock_gettime(A, B)
318
+int xclock_gettime(clockid_t clk_id, struct timespec *tp)
319
 {
320
     pth_int_time (tp);
321
     return 0;
322
EOS
323
    patch bcusdk-0.0.5/eibd/usb/linux_usbfs.c < usb.patch
324
    cd bcusdk-0.0.5
325
    ./configure --enable-onlyeibd --enable-eibnetip --enable-eibnetiptunnel --enable-eibnetipserver --enable-groupcache
326
    make
327
    make install
328
    ldconfig
329

    
330
    useradd eibd -s /bin/false -U -M
331
    cp /home/pi/domotiga/tools/eibd.debian /etc/init.d/eibd
332
    update-rc.d eibd defaults
333
  fi
334

    
335
  if [ "$WEBSERVER" == "LIGHTTPD" ]; then
336
    echo "INFO: Install and configure lighttpd"
337
    apt-get install -y -qq lighttpd php7.0-cgi php7.0-mysql php-apc
338

    
339
    sed -i "s/^;cgi.fix_pathinfo=1/cgi.fix_pathinfo=1/" /etc/php/7.0/cgi/php.ini
340
    sed -i "s/#       "mod_rewrite",/       "mod_rewrite",/" /etc/lighttpd/lighttpd.conf
341

    
342

    
343
    # add required settings to lighttpd.conf
344
    cat >>/etc/lighttpd/lighttpd.conf << EOS
345

    
346
fastcgi.server = ( ".php" => ((
347
                     "bin-path" => "/usr/bin/php5-cgi",
348
                     "socket" => "/tmp/php.socket"
349
                 )))
350

    
351
url.rewrite-if-not-file = (
352
   "domotiyii/.*\?(.*)" => "domotiyii/index.php?\$1",
353
   "domotiyii/." => "domotiyii/index.php"
354
)
355
EOS
356

    
357
    # Enable fast cgi
358
    lighttpd-enable-mod fastcgi
359
  fi
360

    
361
  if [ "$WEBSERVER" == "NGINX" ]; then
362
    echo "### Install and configure nginx"
363
    apt-get install -y -qq nginx php7.0 php7.0-fpm php7.0-json php7.0-mysql
364

    
365
    cat >/etc/nginx/sites-enabled/default << EOS
366
server {
367

    
368
    listen 80;
369
    #listen [::]:80 default_server ipv6only=on;
370

    
371
    server_name  DomotiGa;
372
    root   /var/www;
373
    set \\\$yii_bootstrap "index.php";
374

    
375
    charset utf-8;
376

    
377
    location / {
378
        index  index.html index.php;
379
        try_files \\\$uri \\\$uri/ /\\\$yii_bootstrap?\\\$args;
380

    
381
        location ~ ^/(protected|framework|themes/\w+/views) {
382
            deny  all;
383
        }
384

    
385
        #avoid processing of calls to unexisting static files by yii
386
        location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar|txt)\\\\$ {
387
            try_files \\\$uri =404;
388
            #For production servers you can set expires header with a long period
389
            #expires 3M;
390
        }
391

    
392
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
393
        #
394
        location ~ \.php {
395
            fastcgi_split_path_info  ^(.+\.php)(.*)\\\$;
396
            # NOTE: You should have "cgi.fix_pathinfo = 0" in php.ini
397

    
398
            #let yii catch the calls to unexising PHP files
399
            set \\\$fsn /\\\$yii_bootstrap;
400
            if (-f \\\$document_root\\\$fastcgi_script_name){
401
                set \\\$fsn \\\$fastcgi_script_name;
402
            }
403

    
404
            fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
405
            include fastcgi_params;
406

    
407
            fastcgi_param  SCRIPT_FILENAME  \\\$document_root\\\$fsn;
408

    
409
            #PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI
410
            fastcgi_param  PATH_INFO        \\\$fastcgi_path_info;
411
            fastcgi_param  PATH_TRANSLATED  \\\$document_root\\\$fsn;
412
        }
413

    
414
        location ~ /\.(ht|git) {
415
            deny  all;
416
        }
417

    
418
    }
419

    
420
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 for other sub dirs
421
    location ~ \.php {
422
        fastcgi_split_path_info  ^(.+\.php)(.*)\$;
423
        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
424

    
425
        fastcgi_pass   unix:/var/run/php/php7.0-fpm.sock; 
426
        include fastcgi_params;
427
    }
428

    
429
}
430
EOS
431
    # Lets fix the previously failure with nginx
432
    apt-get -f -y install
433

    
434
    # Remove faulty www.conf?
435
    rm -f /etc/php/7.0/fpm/pool.d/www.conf
436

    
437
    cat >/etc/php/7.0/fpm/pool.d/phpfpm.conf <<EOS
438
[phpfpm]
439

    
440
listen = /var/run/php/php7.0-fpm.sock
441
listen.owner = www-data
442
listen.group = www-data
443
listen.mode = 0666
444
;listen.backlog = 4096
445
user = www-data
446
group = www-data
447
pm = dynamic
448
pm.max_children = 5
449
pm.start_servers = 2
450
pm.min_spare_servers = 1
451
pm.max_spare_servers = 3
452
pm.status_path = /fpm-status
453
ping.path = /fpm-ping
454
ping.response = pong
455
chdir = /var/www
456
catch_workers_output = yes
457

    
458
request_terminate_timeout = 180s
459

    
460
; The following php_admin_* settings below, override php.ini settings
461
php_admin_value[error_log] = /var/log/fpm-php-error.log
462

    
463
; The following settings are specifically used on development sites
464
; Should review/disable for production site
465
php_admin_value[max_execution_time] = 180
466
php_admin_flag[log_errors] = on
467
php_admin_value[memory_limit] = 50m
468
php_admin_value[error_reporting] = E_ALL
469
php_admin_flag[display_errors] = on
470
php_admin_flag[display_startup_errors] = on
471
EOS
472

    
473
    # Add required pathinfo fix
474
    cat >>/etc/php/7.0/fpm/php.ini << EOS
475
cgi.fix_pathinfo=0
476
EOS
477

    
478
  fi
479

    
480
  echo "### Checkout and copy domotiyii into /var/www"
481
  mkdir -p /var/www
482
  git clone --single-branch https://github.com/DomotiGa/DomotiYii.git /home/pi/install/domotiyii
483
  cp -rp /home/pi/install/domotiyii/domotiyii/* /var/www/
484
  rm -rf /home/pi/install/domotiyii
485
  chown -R www-data:www-data /var/www
486

    
487
  # Cleanup
488
  apt-get -y autoremove
489
  apt-get clean
490

    
491
  echo "### Fill the disk with one file with zerooooos"
492
  dd if=/dev/zero of=/zerofile.txt count=100 bs=10M
493
  rm -f /zerofile.txt
494

    
495
  # cleanup work directories
496
  rm -rf /home/pi/install
497
EOF
498

    
499
    # Make script executable
500
    chmod a+x home/pi/install/domotiga.sh
501

    
502
    # Last, but not least - copy our own script into /var/tmp
503
    cp $MYSCRIPT var/tmp/install.sh
504

    
505
  popd
506

    
507
fi
508

    
509
# Called from CustomPiOS common.sh
510
unmount_image $MNTDIR force
511

    
512
################################################################################
513
# Kernel stuff
514
# https://github.com/dhruvvyas90/qemu-rpi-kernel/issues/48
515
################################################################################
516

    
517
KERNEL_VERSION=kernel-qemu-4.9.59-stretch
518
DTB_VERSION=versatile-pb.dtb
519
KERNEL_PATH=~/install/${KERNEL_VERSION}
520
DTB_PATH=~/install/${DTB_VERSION}
521

    
522
if [ ! -f "${KERNEL_PATH}" ] ; then
523
    wget https://github.com/dhruvvyas90/qemu-rpi-kernel/raw/master/${KERNEL_VERSION} -O "${KERNEL_PATH}"
524
fi
525

    
526
if [ ! -f "${DTB_PATH}" ] ; then
527
    wget https://github.com/dhruvvyas90/qemu-rpi-kernel/raw/master/${DTB_VERSION} -O "${DTB_PATH}"
528
fi
529

    
530
################################################################################
531
# Create qemu-run.sh script
532
################################################################################
533

    
534
echo "INFO: Creating QEMU run script '~/install/qemu-run.sh'"
535
cat >~/install/qemu-run.sh << EOF
536
#!/bin/bash
537
/usr/bin/qemu-system-arm -kernel $KERNEL_PATH -cpu arm1176 -m 256 -M versatilepb -dtb $DTB_PATH -no-reboot -serial stdio -append 'root=/dev/sda2 panic=1 rootfstype=ext4 rw' -hda $IMG -net nic -net user,hostfwd=tcp::5022-:22,hostfwd=tcp::5080-:80
538
EOF
539

    
540
# Make script executable
541
chmod a+x ~/install/qemu-run.sh
542

    
543
################################################################################
544
# Create temporary mount/umount
545
################################################################################
546

    
547
echo "INFO: Creating QEMU mount script '~/install/qemu-mount.sh'"
548
cat >~/install/qemu-mount.sh << EOF
549
#!/bin/bash
550
source $MYDIR/custompios-common.sh
551
mount_image $IMG 2 $MNTDIR
552
/bin/bash
553
unmount_image $MNTDIR force
554
EOF
555

    
556
# Make script executable
557
chmod a+x ~/install/qemu-mount.sh
558

    
559
################################################################################
560
# Generate Clean-Up Script
561
################################################################################
562

    
563
echo "INFO: Creating Raspberry Pi fix script '~/install/qemu-cleanup.sh'"
564
cat >~/install/qemu-cleanup.sh << EOF
565
#!/bin/bash
566

    
567
source $MYDIR/custompios-common.sh
568
mount_image $IMG 2 $MNTDIR
569

    
570
cd $MNTDIR
571

    
572
# #######################################
573
# Check that we aren't in the Ubuntu root
574
# #######################################
575
FSTAB=\`readlink -f etc/fstab\`
576

    
577
if [ "\$SFTAB" == "/etc/fstab" ]; then
578
  echo "### ERROR: The currently directly looks to be '/' and isn't allowed"
579
  exit 1
580
fi
581

    
582
if [ ! -f etc/fstab ]; then
583
  echo "ERROR: Raspberry Pi image doesn't seem to be mount"
584
  exit 1
585
fi
586

    
587
# ###################################
588
# Revert/copy back the original files
589
# ###################################
590
cp ~/install/pi-backup/ssh.override etc/init/ssh.override
591
cp ~/install/pi-backup/resize2fs_once etc/init.d/resize2fs_once
592
cp ~/install/pi-backup/fake-hwclock.data etc/fake-hwclock.data
593
cp ~/install/pi-backup/resolv.conf etc/resolv.conf
594

    
595
# ####################################################
596
# Modify the Pi environment back to its original state
597
# ####################################################
598
cp ~/install/pi-backup/ld.so.preload etc/
599
cp ~/install/pi-backup/fstab etc/
600

    
601
# ###########
602
# Empty files
603
# ###########
604
>etc/machine-id
605
>var/log/lastlog
606
>run/wtmp
607

    
608
# ################################
609
# Remove created files/directories
610
# ################################
611
rm -rf etc/dhcpcd.duid
612
rm -rf etc/dhcpcd.secret
613
rm -rf etc/.fstab
614
rm -rf etc/resolv.conf.bak
615
rm -rf etc/ssh/ssh_host_dsa_key
616
rm -rf etc/ssh/ssh_host_dsa_key.pub
617
rm -rf etc/ssh/ssh_host_ecdsa_key
618
rm -rf etc/ssh/ssh_host_ecdsa_key.pub
619
rm -rf etc/ssh/ssh_host_ed25519_key
620
rm -rf etc/ssh/ssh_host_ed25519_key.pub
621
rm -rf etc/ssh/ssh_host_rsa_key
622
rm -rf etc/ssh/ssh_host_rsa_key.pub
623
rm -rf home/pi/.bash_history
624
rm -rf var/cache/unbound/resolvconf_resolvers.conf
625
rm -rf var/lib/dhcpcd5/dhcpcd-eth0.lease
626
rm -rf var/lib/plymouth/boot-duration
627
rm -rf var/lib/systemd/clock
628
rm -rf var/lib/systemd/random-seed
629
rm -rf var/lib/systemd/timers/stamp-apt-daily.timer
630
rm -rf var/lib/systemd/timers/stamp-apt-daily-upgrade.timer
631
rm -rf var/log/auth.log
632
rm -rf var/log/boot.log
633
rm -rf var/log/daemon.log
634
rm -rf var/log/debug
635
rm -rf var/log/kern.log
636
rm -rf var/log/messages
637
rm -rf var/log/syslog
638
rm -rf var/swap
639

    
640
cd ~
641
unmount_image $MNTDIR force
642

    
643
# End of file
644

    
645
EOF
646

    
647
chmod a+x ~/install/qemu-cleanup.sh
648

    
649
###
650
### END
651
###