浏览代码

Random initial image password

Bob Mottram 9 年前
父节点
当前提交
2294979689
共有 1 个文件被更改,包括 15 次插入7 次删除
  1. 15
    7
      src/freedombone-image-customise

+ 15
- 7
src/freedombone-image-customise 查看文件

186
 
186
 
187
 create_generic_image() {
187
 create_generic_image() {
188
     if [[ $GENERIC_IMAGE == "no" ]]; then
188
     if [[ $GENERIC_IMAGE == "no" ]]; then
189
-		return
190
-	fi
189
+        return
190
+    fi
191
     # Don't install any configuration. This will be a base system
191
     # Don't install any configuration. This will be a base system
192
     CONFIG_FILENAME=
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
     touch $rootdir/home/$MY_USERNAME/.initial_setup
195
     touch $rootdir/home/$MY_USERNAME/.initial_setup
196
     touch $rootdir/home/root/.bashrc
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
 # initial setup of the system
199
 # initial setup of the system
200
 if [ -f ~/.initial_setup ]; then
200
 if [ -f ~/.initial_setup ]; then
201
     clear
201
     clear
213
     echo ''
213
     echo ''
214
 
214
 
215
     NEW_USER_PASSWORD="$(openssl rand -base64 12 | cut -c1-10)"
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
     echo "    $NEW_USER_PASSWORD"
217
     echo "    $NEW_USER_PASSWORD"
218
 
218
 
219
     echo ''
219
     echo ''
226
 fi
226
 fi
227
 EOF
227
 EOF
228
 
228
 
229
-	cat >> $rootdir/home/root/.bashrc <<EOF
229
+    cat >> $rootdir/home/root/.bashrc <<EOF
230
 # initial setup of the system
230
 # initial setup of the system
231
 if [ -f ~/.initial_setup ]; then
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
     freedombone menuconfig
237
     freedombone menuconfig
233
     rm ~/.initial_setup
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
 fi
242
 fi
235
 EOF
243
 EOF
236
 }
244
 }