/
correct_live_install
44 lines (37 loc) · 1.54 KB
/
correct_live_install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
# delete the icon 'install' on desktops and installation guides
rm -rf /home/*/Desktop/{install.desktop,img/,Installation_guide.html} /etc/skel/Desktop/{install.desktop,img/,Installation_guide.html}
U="opencpn"
if [ $(/bin/ls -1 /home |wc -l) != 1 ]; then
# this user isn't needed anymore
userdel -r $U
else
# if the user kept the same username, we "refresh" his directory
rm -rf /home/$U/
cp -r /etc/skel/ /home/$U/
chown -R $U:users /home/$U/
fi
# modifying grub config and rebuild grub
grub_file='/etc/default/grub'
. /studio/profile
if [ -e $grub_file ]; then
# changing the menu entry for our distribution if needed
DISTRIB_NAME=$(sed -n 7p $grub_file |awk 'BEGIN {FS="\""};{print $2}')
if [ "$DISTRIB_NAME" != "OpenCPN distribution" ] ; then
sed -i -e "7s/GRUB_DISTRIBUTOR=\"openSUSE 12.3\"/GRUB_DISTRIBUTOR=\"OpenCPN distribution ($kiwi_iversion)\"/" $grub_file
grub2-mkconfig -o /boot/grub2/grub.cfg
fi
fi
# add a crontab to force the brightness (xscreensaver changes when it resumes)
# and force the disk(s) to stop
echo "*/2 * * * * /usr/bin/brightness nosleep" > /tmp/cron_task
ROOT=$(mount -l | grep ' on / '| awk '{print $1}')
# produce :
# * * * * * hdparm -Y /dev/sda1 ; [hdparm -Y /dev/sdX ; ]...
echo "*/10 * * * * " $(for i in $ROOT ; do echo "hdparm -Y $i ; " ; done) >> /tmp/cron_task
crontab /tmp/cron_task
rm /tmp/cron_task
# mount /tmp in ram
echo "tmpfs /tmp tmpfs defaults,size=100M 0 0" >> /etc/fstab
systemctl enable rwramd.service
systemctl enable powertips.service