Ver código fonte

Random initial image password

Bob Mottram 9 anos atrás
pai
commit
2294979689
1 arquivos alterados com 15 adições e 7 exclusões
  1. 15
    7
      src/freedombone-image-customise

+ 15
- 7
src/freedombone-image-customise Ver arquivo

@@ -186,16 +186,16 @@ admin_user_sudo() {
186 186
 
187 187
 create_generic_image() {
188 188
     if [[ $GENERIC_IMAGE == "no" ]]; then
189
-		return
190
-	fi
189
+        return
190
+    fi
191 191
     # Don't install any configuration. This will be a base system
192 192
     CONFIG_FILENAME=
193
-	# The presence of this file indicates that the initial
194
-	# setup has not yet been completed
193
+    # The presence of this file indicates that the initial
194
+    # setup has not yet been completed
195 195
     touch $rootdir/home/$MY_USERNAME/.initial_setup
196 196
     touch $rootdir/home/root/.bashrc
197 197
    
198
-	cat >> $rootdir/home/$MY_USERNAME/.bashrc <<EOF
198
+    cat >> $rootdir/home/$MY_USERNAME/.bashrc <<EOF
199 199
 # initial setup of the system
200 200
 if [ -f ~/.initial_setup ]; then
201 201
     clear
@@ -213,7 +213,7 @@ if [ -f ~/.initial_setup ]; then
213 213
     echo ''
214 214
 
215 215
     NEW_USER_PASSWORD="$(openssl rand -base64 12 | cut -c1-10)"
216
-    echo "${USER}:${NEW_USER_PASSWORD}"|chpasswd
216
+    echo "${NEW_USER_PASSWORD}" > ~/login.txt
217 217
     echo "    $NEW_USER_PASSWORD"
218 218
 
219 219
     echo ''
@@ -226,11 +226,19 @@ if [ -f ~/.initial_setup ]; then
226 226
 fi
227 227
 EOF
228 228
 
229
-	cat >> $rootdir/home/root/.bashrc <<EOF
229
+    cat >> $rootdir/home/root/.bashrc <<EOF
230 230
 # initial setup of the system
231 231
 if [ -f ~/.initial_setup ]; then
232
+EOF
233
+    echo -n "    echo \"${MY_USERNAME}:" >> /home/root/.bashrc
234
+    echo -n '$(cat /home/'  >> /home/root/.bashrc
235
+    echo "${MY_USERNAME}/login.txt)\"|chpasswd" >> /home/root/.bashrc
236
+    cat >> $rootdir/home/root/.bashrc <<EOF
232 237
     freedombone menuconfig
233 238
     rm ~/.initial_setup
239
+EOF
240
+    echo "    shred -zu /home/${MY_USERNAME}/login.txt" >> $rootdir/home/root/.bashrc
241
+    cat >> $rootdir/home/root/.bashrc <<EOF
234 242
 fi
235 243
 EOF
236 244
 }