@@ -136,55 +136,68 @@ def stdOut(message, log=0, do_exit=0, code=os.EX_OK):
136136
137137 def mountTemp (self ):
138138 try :
139- command = "dd if=/dev/zero of=/usr/.tempdisk bs=100M count=15"
140- preFlightsChecks .call (command , self .distro , '[mountTemp]' ,
141- 'mountTemp' ,
142- 1 , 0 , os .EX_OSERR )
139+ ## On OpenVZ there is an issue using .tempdisk for /tmp as it breaks network on container after reboot.
143140
144- command = "mkfs.ext4 -F /usr/.tempdisk"
145- preFlightsChecks .call (command , self .distro , '[mountTemp]' ,
146- 'mountTemp' ,
147- 1 , 0 , os .EX_OSERR )
141+ if subprocess .check_output ('systemd-detect-virt' ).find ("openvz" ) > - 1 :
148142
149- command = "mkdir -p /usr/.tmpbak/"
150- preFlightsChecks .call (command , self .distro , '[mountTemp]' ,
151- 'mountTemp' ,
152- 1 , 0 , os .EX_OSERR )
143+ varTmp = "/var/tmp /tmp none bind 0 0\n "
153144
154- command = "cp -pr /tmp/* /usr/.tmpbak/"
155- subprocess .call (command , shell = True )
145+ fstab = "/etc/fstab"
146+ writeToFile = open (fstab , "a" )
147+ writeToFile .writelines (varTmp )
148+ writeToFile .close ()
156149
157- command = "mount -o loop,rw,nodev,nosuid,noexec,nofail /usr/.tempdisk /tmp"
158- preFlightsChecks .call (command , self .distro , '[mountTemp]' ,
159- 'mountTemp' ,
160- 1 , 0 , os .EX_OSERR )
150+ else :
161151
162- command = "chmod 1777 /tmp "
163- preFlightsChecks .call (command , self .distro , '[mountTemp]' ,
164- 'mountTemp' ,
165- 1 , 0 , os .EX_OSERR )
152+ command = "dd if=/dev/zero of=/usr/.tempdisk bs=100M count=15 "
153+ preFlightsChecks .call (command , self .distro , '[mountTemp]' ,
154+ 'mountTemp' ,
155+ 1 , 0 , os .EX_OSERR )
166156
167- command = "cp -pr /usr/.tmpbak/* /tmp/"
168- subprocess .call (command , shell = True )
157+ command = "mkfs.ext4 -F /usr/.tempdisk"
158+ preFlightsChecks .call (command , self .distro , '[mountTemp]' ,
159+ 'mountTemp' ,
160+ 1 , 0 , os .EX_OSERR )
169161
170- command = "rm -rf /usr/.tmpbak"
171- preFlightsChecks .call (command , self .distro , '[mountTemp]' ,
172- 'mountTemp' ,
173- 1 , 0 , os .EX_OSERR )
162+ command = "mkdir -p /usr/.tmpbak/ "
163+ preFlightsChecks .call (command , self .distro , '[mountTemp]' ,
164+ 'mountTemp' ,
165+ 1 , 0 , os .EX_OSERR )
174166
175- command = "mount --bind /tmp /var/tmp"
176- preFlightsChecks .call (command , self .distro , '[mountTemp]' ,
177- 'mountTemp' ,
178- 1 , 0 , os .EX_OSERR )
167+ command = "cp -pr /tmp/* /usr/.tmpbak/"
168+ subprocess .call (command , shell = True )
179169
180- tmp = "/usr/.tempdisk /tmp ext4 loop,rw,noexec,nosuid,nodev,nofail 0 0\n "
181- varTmp = "/tmp /var/tmp none bind 0 0\n "
170+ command = "mount -o loop,rw,nodev,nosuid,noexec,nofail /usr/.tempdisk /tmp"
171+ preFlightsChecks .call (command , self .distro , '[mountTemp]' ,
172+ 'mountTemp' ,
173+ 1 , 0 , os .EX_OSERR )
182174
183- fstab = "/etc/fstab"
184- writeToFile = open (fstab , "a" )
185- writeToFile .writelines (tmp )
186- writeToFile .writelines (varTmp )
187- writeToFile .close ()
175+ command = "chmod 1777 /tmp"
176+ preFlightsChecks .call (command , self .distro , '[mountTemp]' ,
177+ 'mountTemp' ,
178+ 1 , 0 , os .EX_OSERR )
179+
180+ command = "cp -pr /usr/.tmpbak/* /tmp/"
181+ subprocess .call (command , shell = True )
182+
183+ command = "rm -rf /usr/.tmpbak"
184+ preFlightsChecks .call (command , self .distro , '[mountTemp]' ,
185+ 'mountTemp' ,
186+ 1 , 0 , os .EX_OSERR )
187+
188+ command = "mount --bind /tmp /var/tmp"
189+ preFlightsChecks .call (command , self .distro , '[mountTemp]' ,
190+ 'mountTemp' ,
191+ 1 , 0 , os .EX_OSERR )
192+
193+ tmp = "/usr/.tempdisk /tmp ext4 loop,rw,noexec,nosuid,nodev,nofail 0 0\n "
194+ varTmp = "/tmp /var/tmp none bind 0 0\n "
195+
196+ fstab = "/etc/fstab"
197+ writeToFile = open (fstab , "a" )
198+ writeToFile .writelines (tmp )
199+ writeToFile .writelines (varTmp )
200+ writeToFile .close ()
188201
189202 except BaseException , msg :
190203 preFlightsChecks .stdOut ("[Failed:mountTemp] " + str (msg ))
0 commit comments