Change-Id: Ic520ec1026c6cb73296baba43c2ff7d55b36066d
Reviewed-on: http://photon-jenkins.eng.vmware.com/95
Reviewed-by: <anishs@vmware.com>
Tested-by: jenkins-photon <wangnan2015@hotmail.com>
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,15 @@ |
| 0 |
+diff -uNr iperf-3.1_orig/src/Makefile.am iperf-3.1/src/Makefile.am |
|
| 1 |
+--- iperf-3.1_orig/src/Makefile.am 2015-10-16 10:01:09.000000000 -0700 |
|
| 2 |
+@@ -49,9 +49,9 @@ |
|
| 3 |
+ iperf3_profile_SOURCES = main.c \ |
|
| 4 |
+ $(libiperf_la_SOURCES) |
|
| 5 |
+ |
|
| 6 |
+-iperf3_profile_CFLAGS = -pg -g |
|
| 7 |
++iperf3_profile_CFLAGS = -g |
|
| 8 |
+ iperf3_profile_LDADD = libiperf.la |
|
| 9 |
+-iperf3_profile_LDFLAGS = -pg -g |
|
| 10 |
++iperf3_profile_LDFLAGS = -g |
|
| 11 |
+ |
|
| 12 |
+ # Specify the sources and various flags for the test cases |
|
| 13 |
+ t_timer_SOURCES = t_timer.c |
| 0 | 14 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,68 @@ |
| 0 |
+Summary: A network performance benchmark tool. |
|
| 1 |
+Name: iperf |
|
| 2 |
+Version: 3.1 |
|
| 3 |
+Release: 1%{?dist}
|
|
| 4 |
+License: GPL |
|
| 5 |
+URL: https://github.com/esnet/iperf |
|
| 6 |
+Group: Applications/System |
|
| 7 |
+Vendor: VMware, Inc. |
|
| 8 |
+Distribution: Photon |
|
| 9 |
+#Source download URL: https://github.com/esnet/iperf/archive/3.1.tar.gz |
|
| 10 |
+Source0: https://github.com/esnet/iperf/archive/%{name}-%{version}.tar.gz
|
|
| 11 |
+Patch1: disablepg.patch |
|
| 12 |
+%define sha1 iperf=0e00ce535b02b869b53649ef50fc1516a49c858c |
|
| 13 |
+BuildRequires: autoconf |
|
| 14 |
+BuildRequires: automake |
|
| 15 |
+ |
|
| 16 |
+%description |
|
| 17 |
+ipref is a network performance measurement tool that can measure the maximum |
|
| 18 |
+achievable network bandwidth on IP networks. It supports tuning of various |
|
| 19 |
+parameters related to timing, protocols, and buffers. For each test it |
|
| 20 |
+reports the bandwidth, loss, and other parameters. |
|
| 21 |
+ |
|
| 22 |
+%package doc |
|
| 23 |
+Summary: Documentation for iperf |
|
| 24 |
+%description doc |
|
| 25 |
+It contains the documentation and manpages for iperf package. |
|
| 26 |
+Requires: %{name} = %{version}-%{release}
|
|
| 27 |
+ |
|
| 28 |
+%prep |
|
| 29 |
+%setup -q |
|
| 30 |
+%patch1 -p1 |
|
| 31 |
+ |
|
| 32 |
+%build |
|
| 33 |
+echo "VDBG optflags: " %{optflags}
|
|
| 34 |
+./bootstrap.sh |
|
| 35 |
+./configure \ |
|
| 36 |
+ CFLAGS="%{optflags}" \
|
|
| 37 |
+ CXXFLAGS="%{optflags}" \
|
|
| 38 |
+ --disable-silent-rules \ |
|
| 39 |
+ --prefix=%{_prefix} \
|
|
| 40 |
+ --bindir=%{_bindir} \
|
|
| 41 |
+ --sbindir=%{_sbindir} \
|
|
| 42 |
+ --includedir=%{_includedir} \
|
|
| 43 |
+ --libdir=%{_libdir} \
|
|
| 44 |
+ --mandir=%{_mandir} \
|
|
| 45 |
+ --infodir=%{_infodir} \
|
|
| 46 |
+ --datadir=%{_datarootdir} \
|
|
| 47 |
+ --sysconfdir=/etc |
|
| 48 |
+make %{?_smp_mflags}
|
|
| 49 |
+ |
|
| 50 |
+%install |
|
| 51 |
+[ %{buildroot} != "/"] && rm -rf %{buildroot}/*
|
|
| 52 |
+make DESTDIR=%{buildroot} install
|
|
| 53 |
+ |
|
| 54 |
+%files |
|
| 55 |
+%defattr(-,root,root) |
|
| 56 |
+%{_bindir}/iperf3
|
|
| 57 |
+%{_includedir}/iperf_api.h
|
|
| 58 |
+%{_libdir}/libiperf.*
|
|
| 59 |
+ |
|
| 60 |
+%files doc |
|
| 61 |
+%defattr(-,root,root,-) |
|
| 62 |
+%{_mandir}/man1/iperf3.1.gz
|
|
| 63 |
+%{_mandir}/man3/libiperf.3.gz
|
|
| 64 |
+ |
|
| 65 |
+%changelog |
|
| 66 |
+* Wed Oct 28 2015 Vinay Kulkarni <kulkarniv@vmware.com> 2.7.0-1 |
|
| 67 |
+- Add iperf v3.1 package. |
| 0 | 68 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,14 @@ |
| 0 |
+{
|
|
| 1 |
+ "minimal" : {
|
|
| 2 |
+ "title" : "Photon Minimal", |
|
| 3 |
+ "file" : "packages_minimal_ova.json", |
|
| 4 |
+ "visible" : true, |
|
| 5 |
+ "include" : [] |
|
| 6 |
+ }, |
|
| 7 |
+ "ovs" : {
|
|
| 8 |
+ "title" : "Photon OVS packages", |
|
| 9 |
+ "file" : "packages_ovs.json", |
|
| 10 |
+ "visible" : true, |
|
| 11 |
+ "include" : ["minimal"] |
|
| 12 |
+ } |
|
| 13 |
+} |
| ... | ... |
@@ -9,5 +9,5 @@ |
| 9 | 9 |
"dhcp-client","dhcp-server","dhcp-libs","dhcp-devel","initscripts","net-tools", |
| 10 | 10 |
"jaxws-ri","commons-daemon","runit", "python-pyasn1", "WALinuxAgent", "linux-esx", |
| 11 | 11 |
"python-Twisted", "python-zope.interface", "python-ipaddr", "chkconfig", "libnss-ato", |
| 12 |
- "procmail","dmidecode"] |
|
| 12 |
+ "procmail","dmidecode","iperf"] |
|
| 13 | 13 |
} |
| ... | ... |
@@ -34,7 +34,7 @@ cp $VMDK_CONFIG_FILE $VMDK_CONFIG_SAFE_FILE |
| 34 | 34 |
cp ${BUILD_SCRIPTS_PATH}/mk-setup-vmdk.sh .
|
| 35 | 35 |
cp ${BUILD_SCRIPTS_PATH}/mk-clean-vmdk.sh .
|
| 36 | 36 |
|
| 37 |
-if [ $IMG_NAME != "ova" ] && [ $IMG_NAME != "ova_uefi" ] |
|
| 37 |
+if [ $IMG_NAME != "ova" ] && [ $IMG_NAME != "ova_uefi" ] && [ $IMG_NAME != "ova_ovs" ] |
|
| 38 | 38 |
then |
| 39 | 39 |
cp ${BUILD_SCRIPTS_PATH}/mk-setup-grub.sh .
|
| 40 | 40 |
fi |
| ... | ... |
@@ -54,6 +54,7 @@ if [ -n "$ADDITIONAL_RPMS_PATH" ] |
| 54 | 54 |
fi |
| 55 | 55 |
|
| 56 | 56 |
./photonInstaller.py -p $GENERATED_DATA_PATH/build_install_options_$IMG_NAME.json -r $PHOTON_STAGE_PATH/RPMS -v $INSTALLER_PATH/photon-${IMG_NAME} -o $GENERATED_DATA_PATH -f $VMDK_CONFIG_SAFE_FILE
|
| 57 |
+cat $VMDK_CONFIG_SAFE_FILE |
|
| 57 | 58 |
rm $VMDK_CONFIG_SAFE_FILE |
| 58 | 59 |
|
| 59 | 60 |
cd $BUILD_SCRIPTS_PATH |
| ... | ... |
@@ -94,7 +95,7 @@ if [ -n "$ADDITIONAL_RPMS_PATH" ] |
| 94 | 94 |
rm -rf $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/additional_rpms/
|
| 95 | 95 |
fi |
| 96 | 96 |
|
| 97 |
-if [ $IMG_NAME != "ova" ] && [ $IMG_NAME != "ova_uefi" ] |
|
| 97 |
+if [ $IMG_NAME != "ova" ] && [ $IMG_NAME != "ova_uefi" ] && [ $IMG_NAME != "ova_ovs" ] |
|
| 98 | 98 |
then |
| 99 | 99 |
#Copy the initrd image |
| 100 | 100 |
rm -rf /tmp/initrd* |
| ... | ... |
@@ -11,7 +11,7 @@ rm -f $PHOTON_IMG_OUTPUT_PATH/*.ova |
| 11 | 11 |
sed "s|VMDK_IMAGE|$PHOTON_IMG_OUTPUT_PATH/photon-ova.vmdk|" vmx-template > /tmp/vmx-temp.vmx |
| 12 | 12 |
sed "s|VMDK_IMAGE|$PHOTON_IMG_OUTPUT_PATH/photon-custom.vmdk|" vmx-template > /tmp/vmx-temp-custom.vmx |
| 13 | 13 |
|
| 14 |
-cp update_custom_password.py $PHOTON_IMG_OUTPUT_PATH/ |
|
| 14 |
+cp ../update_custom_password.py $PHOTON_IMG_OUTPUT_PATH/ |
|
| 15 | 15 |
|
| 16 | 16 |
cd $SRC_ROOT/tools/src/vixDiskUtil |
| 17 | 17 |
mkdir -p $SRC_ROOT/tools/bin |
| 18 | 18 |
deleted file mode 100755 |
| ... | ... |
@@ -1,32 +0,0 @@ |
| 1 |
-#!/usr/bin/python2 |
|
| 2 |
- |
|
| 3 |
-import os |
|
| 4 |
-import crypt |
|
| 5 |
-import random |
|
| 6 |
-import string |
|
| 7 |
-import sys |
|
| 8 |
-import re |
|
| 9 |
- |
|
| 10 |
- |
|
| 11 |
-def crypt_password(password, root_path): |
|
| 12 |
- shadow_password = crypt.crypt(password, "$6$" + "".join([random.choice(string.ascii_letters + string.digits) for _ in range(16)])) |
|
| 13 |
- |
|
| 14 |
- shadow_filename = os.path.join(root_path, 'etc/shadow') |
|
| 15 |
- |
|
| 16 |
- if os.path.isfile(shadow_filename) == False: |
|
| 17 |
- with open(shadow_filename, "w") as destination: |
|
| 18 |
- destination.write("root:"+shadow_password+":")
|
|
| 19 |
- else: |
|
| 20 |
- #add password hash in shadow file |
|
| 21 |
- with open(shadow_filename, "r") as source: |
|
| 22 |
- lines=source.readlines() |
|
| 23 |
- |
|
| 24 |
- with open(shadow_filename, "w") as destination: |
|
| 25 |
- for line in lines: |
|
| 26 |
- destination.write(re.sub("root:x:", "root:"+shadow_password+":", line))
|
|
| 27 |
- |
|
| 28 |
-if __name__ == '__main__': |
|
| 29 |
- if len(sys.argv) < 3: |
|
| 30 |
- print ("Usage : update_custom_password.py <password> <root_path>")
|
|
| 31 |
- sys.exit(1) |
|
| 32 |
- crypt_password(str(sys.argv[1]), str(sys.argv[2])) |
| ... | ... |
@@ -11,7 +11,7 @@ rm -f $PHOTON_IMG_OUTPUT_PATH/*.ova |
| 11 | 11 |
sed "s|VMDK_IMAGE|$PHOTON_IMG_OUTPUT_PATH/photon-generic-ova.vmdk|" vmx-generic-template > /tmp/vmx-generic-temp.vmx |
| 12 | 12 |
sed "s|VMDK_IMAGE|$PHOTON_IMG_OUTPUT_PATH/photon-generic-custom.vmdk|" vmx-generic-template > /tmp/vmx-generic-temp-custom.vmx |
| 13 | 13 |
|
| 14 |
-cp update_custom_password.py $PHOTON_IMG_OUTPUT_PATH/ |
|
| 14 |
+cp ../update_custom_password.py $PHOTON_IMG_OUTPUT_PATH/ |
|
| 15 | 15 |
|
| 16 | 16 |
cd $SRC_ROOT/tools/src/vixDiskUtil |
| 17 | 17 |
mkdir -p $SRC_ROOT/tools/bin |
| 18 | 18 |
deleted file mode 100755 |
| ... | ... |
@@ -1,32 +0,0 @@ |
| 1 |
-#!/usr/bin/python2 |
|
| 2 |
- |
|
| 3 |
-import os |
|
| 4 |
-import crypt |
|
| 5 |
-import random |
|
| 6 |
-import string |
|
| 7 |
-import sys |
|
| 8 |
-import re |
|
| 9 |
- |
|
| 10 |
- |
|
| 11 |
-def crypt_password(password, root_path): |
|
| 12 |
- shadow_password = crypt.crypt(password, "$6$" + "".join([random.choice(string.ascii_letters + string.digits) for _ in range(16)])) |
|
| 13 |
- |
|
| 14 |
- shadow_filename = os.path.join(root_path, 'etc/shadow') |
|
| 15 |
- |
|
| 16 |
- if os.path.isfile(shadow_filename) == False: |
|
| 17 |
- with open(shadow_filename, "w") as destination: |
|
| 18 |
- destination.write("root:"+shadow_password+":")
|
|
| 19 |
- else: |
|
| 20 |
- #add password hash in shadow file |
|
| 21 |
- with open(shadow_filename, "r") as source: |
|
| 22 |
- lines=source.readlines() |
|
| 23 |
- |
|
| 24 |
- with open(shadow_filename, "w") as destination: |
|
| 25 |
- for line in lines: |
|
| 26 |
- destination.write(re.sub("root:x:", "root:"+shadow_password+":", line))
|
|
| 27 |
- |
|
| 28 |
-if __name__ == '__main__': |
|
| 29 |
- if len(sys.argv) < 3: |
|
| 30 |
- print ("Usage : update_custom_password.py <password> <root_path>")
|
|
| 31 |
- sys.exit(1) |
|
| 32 |
- crypt_password(str(sys.argv[1]), str(sys.argv[2])) |
| 33 | 1 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,65 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+set -x |
|
| 2 |
+PHOTON_IMG_OUTPUT_PATH=$1 |
|
| 3 |
+SRC_ROOT=$2 |
|
| 4 |
+ |
|
| 5 |
+rm -f $PHOTON_IMG_OUTPUT_PATH/*.vmdk |
|
| 6 |
+rm -f $PHOTON_IMG_OUTPUT_PATH/*.ova |
|
| 7 |
+sed "s|VMDK_IMAGE|$PHOTON_IMG_OUTPUT_PATH/photon-ova-ovs.vmdk|" vmx-ovs-template > /tmp/vmx-temp-ovs.vmx |
|
| 8 |
+ |
|
| 9 |
+cp ../update_custom_password.py $PHOTON_IMG_OUTPUT_PATH/ |
|
| 10 |
+ |
|
| 11 |
+cd $SRC_ROOT/tools/src/vixDiskUtil |
|
| 12 |
+mkdir -p $SRC_ROOT/tools/bin |
|
| 13 |
+make clean |
|
| 14 |
+make |
|
| 15 |
+ |
|
| 16 |
+cd $PHOTON_IMG_OUTPUT_PATH |
|
| 17 |
+ |
|
| 18 |
+DISK_DEVICE=`losetup --show -f ${PHOTON_IMG_OUTPUT_PATH}/photon-ova_ovs.raw`
|
|
| 19 |
+echo "Mapping device partition to loop device" |
|
| 20 |
+kpartx -av $DISK_DEVICE |
|
| 21 |
+DEVICE_NAME=`echo $DISK_DEVICE|cut -c6- ` |
|
| 22 |
+echo "DISK_DEVICE=$DISK_DEVICE" |
|
| 23 |
+echo "ROOT_PARTITION=/dev/mapper/${DEVICE_NAME}p2"
|
|
| 24 |
+ |
|
| 25 |
+rm -rf $PHOTON_IMG_OUTPUT_PATH/photon-ova_ovs |
|
| 26 |
+mkdir $PHOTON_IMG_OUTPUT_PATH/photon-ova_ovs |
|
| 27 |
+ |
|
| 28 |
+mount -v -t ext4 /dev/mapper/${DEVICE_NAME}p2 $PHOTON_IMG_OUTPUT_PATH/photon-ova_ovs
|
|
| 29 |
+rm -f $PHOTON_IMG_OUTPUT_PATH/photon-ova_ovs/etc/systemd/system/multi-user.target.wants/cloud-* |
|
| 30 |
+cp $PHOTON_IMG_OUTPUT_PATH/photon-ova_ovs/etc/shadow $PHOTON_IMG_OUTPUT_PATH/photon-ova_ovs/etc/shadow.bak |
|
| 31 |
+sed -e "s/^\(root:\)[^:]*:/\1x:/" $PHOTON_IMG_OUTPUT_PATH/photon-ova_ovs/etc/shadow.bak > $PHOTON_IMG_OUTPUT_PATH/photon-ova_ovs/etc/shadow |
|
| 32 |
+./update_custom_password.py ovs $PHOTON_IMG_OUTPUT_PATH/photon-ova_ovs |
|
| 33 |
+rm -f $PHOTON_IMG_OUTPUT_PATH/photon-ova_ovs/etc/shadow- |
|
| 34 |
+rm -f $PHOTON_IMG_OUTPUT_PATH/photon-ova_ovs/etc/shadow.bak |
|
| 35 |
+umount $PHOTON_IMG_OUTPUT_PATH/photon-ova_ovs |
|
| 36 |
+ |
|
| 37 |
+echo "Deleting device map partition" |
|
| 38 |
+kpartx -d $DISK_DEVICE |
|
| 39 |
+rm -rf $PHOTON_IMG_OUTPUT_PATH/photon-ova_ovs |
|
| 40 |
+echo "Detaching loop device from raw disk" |
|
| 41 |
+losetup -d $DISK_DEVICE |
|
| 42 |
+ |
|
| 43 |
+ |
|
| 44 |
+$SRC_ROOT/tools/bin/vixdiskutil -convert $PHOTON_IMG_OUTPUT_PATH/photon-ova_ovs.raw -cap 16000 $PHOTON_IMG_OUTPUT_PATH/photon-ova-ovs.vmdk |
|
| 45 |
+$SRC_ROOT/tools/bin/vixdiskutil -wmeta toolsVersion 2147483647 $PHOTON_IMG_OUTPUT_PATH/photon-ova-ovs.vmdk |
|
| 46 |
+ |
|
| 47 |
+mkdir -p $PHOTON_IMG_OUTPUT_PATH/temp |
|
| 48 |
+ovftool /tmp/vmx-temp-ovs.vmx $PHOTON_IMG_OUTPUT_PATH/temp/photon-ova-ovs.ovf |
|
| 49 |
+cd $PHOTON_IMG_OUTPUT_PATH/temp |
|
| 50 |
+ |
|
| 51 |
+sed -i "s/otherGuest/other3xLinux64Guest/g" $PHOTON_IMG_OUTPUT_PATH/temp/photon-ova-ovs.ovf |
|
| 52 |
+#disable pcibridge and add uefi metadata |
|
| 53 |
+#sed -i '/vmw:value="efi"\/>/a \ \t<vmw:ExtraConfig ovf:required="false" vmw:key="uefi.secureBoot.enabled" vmw:value="TRUE"/>\n \ \t<vmw:ExtraConfig ovf:required="false" vmw:key="pciBridge5.present" vmw:value="false"/>\n \ \t<vmw:ExtraConfig ovf:required="false" vmw:key="pciBridge6.present" vmw:value="false"/>\n \ \t<vmw:ExtraConfig ovf:required="false" vmw:key="pciBridge7.present" vmw:value="false"/> ' $PHOTON_IMG_OUTPUT_PATH/temp/photon-ova-ovs.ovf |
|
| 54 |
+#Add product info |
|
| 55 |
+sed -i '/\/VirtualSystem>/i \ \t<ProductSection> \n \t\t<Info>Information about the installed software</Info> \n \t\t<Product>Photon</Product> \n \t\t<Vendor>VMware Inc.</Vendor> \n \t\t<Version>1.0.0</Version> \n \t\t<FullVersion>1.0.0-TP3</FullVersion> \n \t</ProductSection> ' $PHOTON_IMG_OUTPUT_PATH/temp/photon-ova-ovs.ovf |
|
| 56 |
+ |
|
| 57 |
+openssl sha1 *.vmdk photon-ova-ovs.ovf > photon-ova-ovs.mf |
|
| 58 |
+tar cf photon-ova-ovs-$PHOTON_RELEASE_VER-$PHOTON_BUILD_NUM.ova photon-ova-ovs.ovf photon-ova-ovs.mf photon-ova-ovs-disk1.vmdk |
|
| 59 |
+cp $PHOTON_IMG_OUTPUT_PATH/temp/photon-ova-ovs-$PHOTON_RELEASE_VER-$PHOTON_BUILD_NUM.ova $PHOTON_IMG_OUTPUT_PATH/ |
|
| 60 |
+ |
|
| 61 |
+rm -rf $PHOTON_IMG_OUTPUT_PATH/temp/ |
|
| 62 |
+ |
|
| 63 |
+rm -f $PHOTON_IMG_OUTPUT_PATH/photon-ova_ovs.raw |
|
| 64 |
+ |
| 0 | 11 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,19 @@ |
| 0 |
+.encoding = "UTF-8" |
|
| 1 |
+virtualHW.version = "13" |
|
| 2 |
+scsi0.present = "TRUE" |
|
| 3 |
+scsi0.virtualDev = "pvscsi" |
|
| 4 |
+scsi0:0.present = "TRUE" |
|
| 5 |
+scsi0:0.fileName = "VMDK_IMAGE" |
|
| 6 |
+ethernet0.present = "TRUE" |
|
| 7 |
+ethernet0.virtualDev = "vmxnet3" |
|
| 8 |
+ethernet0.wakeOnPcktRcv = "FALSE" |
|
| 9 |
+ethernet0.addressType = "generated" |
|
| 10 |
+ethernet0.linkStatePropagation.enable = "TRUE" |
|
| 11 |
+ethernet0.connectionType = "None" |
|
| 12 |
+displayName = "Photon" |
|
| 13 |
+guestOS = "*other26xLinux64Guest" |
|
| 14 |
+memsize = "2048" |
|
| 15 |
+ide1:0.present = "TRUE" |
|
| 16 |
+ide1:0.autodetect = "TRUE" |
|
| 17 |
+ide1:0.deviceType = "cdrom-raw" |
|
| 18 |
+ide1:0.startConnected = "FALSE" |
| 0 | 19 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,32 @@ |
| 0 |
+#!/usr/bin/python2 |
|
| 1 |
+ |
|
| 2 |
+import os |
|
| 3 |
+import crypt |
|
| 4 |
+import random |
|
| 5 |
+import string |
|
| 6 |
+import sys |
|
| 7 |
+import re |
|
| 8 |
+ |
|
| 9 |
+ |
|
| 10 |
+def crypt_password(password, root_path): |
|
| 11 |
+ shadow_password = crypt.crypt(password, "$6$" + "".join([random.choice(string.ascii_letters + string.digits) for _ in range(16)])) |
|
| 12 |
+ |
|
| 13 |
+ shadow_filename = os.path.join(root_path, 'etc/shadow') |
|
| 14 |
+ |
|
| 15 |
+ if os.path.isfile(shadow_filename) == False: |
|
| 16 |
+ with open(shadow_filename, "w") as destination: |
|
| 17 |
+ destination.write("root:"+shadow_password+":")
|
|
| 18 |
+ else: |
|
| 19 |
+ #add password hash in shadow file |
|
| 20 |
+ with open(shadow_filename, "r") as source: |
|
| 21 |
+ lines=source.readlines() |
|
| 22 |
+ |
|
| 23 |
+ with open(shadow_filename, "w") as destination: |
|
| 24 |
+ for line in lines: |
|
| 25 |
+ destination.write(re.sub("root:x:", "root:"+shadow_password+":", line))
|
|
| 26 |
+ |
|
| 27 |
+if __name__ == '__main__': |
|
| 28 |
+ if len(sys.argv) < 3: |
|
| 29 |
+ print ("Usage : update_custom_password.py <password> <root_path>")
|
|
| 30 |
+ sys.exit(1) |
|
| 31 |
+ crypt_password(str(sys.argv[1]), str(sys.argv[2])) |