Bladeren bron

Ensure that default fbone user gets removed on first boot of the non-mesh system

Bob Mottram 7 jaren geleden
bovenliggende
commit
9083b43a67
1 gewijzigde bestanden met toevoegingen van 36 en 0 verwijderingen
  1. 36
    0
      src/freedombone-utils-final

+ 36
- 0
src/freedombone-utils-final Bestand weergeven

91
     cat $COMPLETION_FILE | grep "install_" > /usr/share/${PROJECT_NAME}/installed.txt
91
     cat $COMPLETION_FILE | grep "install_" > /usr/share/${PROJECT_NAME}/installed.txt
92
 }
92
 }
93
 
93
 
94
+function create_default_user_removal_daemon {
95
+    # This daemon runs on first boot and removes the default fbone user
96
+
97
+    first_start_daemon_filename=/etc/systemd/system/firststart.service
98
+    first_start_script=/usr/local/bin/firststart
99
+    echo '#!/bin/bash' > $first_start_script
100
+    echo 'if [ -d /home/fbone]; then' >> $first_start_script
101
+    echo '    userdel -r fbone' >> $first_start_script
102
+    echo '    if [ -d /home/fbone]; then' >> $first_start_script
103
+    echo '        rm -rf /home/fbone' >> $first_start_script
104
+    echo '    fi' >> $first_start_script
105
+    echo 'fi' >> $first_start_script
106
+    echo 'systemctl disable firststart' >> $first_start_script
107
+    echo "rm $first_start_daemon_filename" >> $first_start_script
108
+    chmod +x $first_start_script
109
+
110
+    echo '[Unit]' > $first_start_daemon_filename
111
+    echo 'Description=Daemon run on first boot' >> $first_start_daemon_filename
112
+    echo 'After=syslog.target' >> $first_start_daemon_filename
113
+    echo 'After=network.target' >> $first_start_daemon_filename
114
+    echo '' >> $first_start_daemon_filename
115
+    echo '[Service]' >> $first_start_daemon_filename
116
+    echo 'User=root' >> $first_start_daemon_filename
117
+    echo 'Group=root' >> $first_start_daemon_filename
118
+    echo "ExecStart=$first_start_script" >> $first_start_daemon_filename
119
+    echo 'StandardOutput=syslog' >> $first_start_daemon_filename
120
+    echo 'StandardError=syslog' >> $first_start_daemon_filename
121
+    echo '' >> $first_start_daemon_filename
122
+    echo '[Install]' >> $first_start_daemon_filename
123
+    echo 'WantedBy=multi-user.target' >> $first_start_daemon_filename
124
+    systemctl enable firststart
125
+}
126
+
94
 function setup_final {
127
 function setup_final {
95
     function_check update_installed_apps_list
128
     function_check update_installed_apps_list
96
     update_installed_apps_list
129
     update_installed_apps_list
97
 
130
 
131
+    function_check create_default_user_removal_daemon
132
+    create_default_user_removal_daemon
133
+
98
     function_check install_tripwire
134
     function_check install_tripwire
99
     install_tripwire
135
     install_tripwire
100
 
136