@@ -33,39 +33,37 @@ Step 5: Create a shell file with the below commands in the project and name it a
3333
3434{% highlight c# tabtitle="C#" %}
3535
36- DIR="/home/site/wwwroot/Package"
37- if [ -d "$DIR" ] ; then
38- echo "'$DIR' found and now copying files, please wait ..."
39- PACKAGE_USR="/home/site/wwwroot/Package/usr"
40- if [ -d "$PACKAGE_USR" ] ; then
41- cp -r /home/site/wwwroot/Package/usr/lib/x86_64-linux-gnu/ /usr/lib/
42- fi
43- PACKAGE_LIB="/home/site/wwwroot/Package/lib"
44- if [ -d "$PACKAGE_LIB" ] ; then
45- rm /home/site/wwwroot/Package/lib/x86_64-linux-gnu/libc.so.6;
46- rm /home/site/wwwroot/Package/lib/x86_64-linux-gnu/libc-2.28.so;
47- rm /home/site/wwwroot/Package/lib/x86_64-linux-gnu/libselinux.so.1;
48- cp -r /home/site/wwwroot/Package/lib/x86_64-linux-gnu/ /lib/;
49- ldconfig;
50- fi
36+ echo "Starting dependencies installation script..."
37+
38+ # Ensure rsync is installed
39+ if ! command -v rsync &> /dev/null; then
40+ echo "rsync could not be found, installing..."
41+ apt-get update && apt-get install -yq rsync
42+ fi
43+
44+ FILE_PATH="/home/site/wwwroot/Package/usr/lib/x86_64-linux-gnu/libnss3.so"
45+ if [ -f "$FILE_PATH" ] ; then
46+ echo "Dependencies file exists."
47+ PACKAGE_USR="/home/site/wwwroot/Package/usr/lib/x86_64-linux-gnu"
48+ if [ -d "$PACKAGE_USR" ] ; then
49+ echo "Copying user libraries..."
50+ rsync -av --update /home/site/wwwroot/Package/usr/lib/ /usr/lib/
51+ echo "copied successfully..."
52+ fi
5153else
52- apt-get update && apt-get install -yq --no-install-recommends libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 libnss3 libgbm1;
53- mkdir /home/site/wwwroot/Package;
54- mkdir /home/site/wwwroot/Package/usr;
55- mkdir /home/site/wwwroot/Package/usr/lib;
56- mkdir /home/site/wwwroot/Package/usr/lib/x86_64-linux-gnu;
57- mkdir /home/site/wwwroot/Package/lib;
58- mkdir /home/site/wwwroot/Package/lib/x86_64-linux-gnu;
59- PACKAGE_USR="/home/site/wwwroot/Package/usr"
60- if [ -d "$PACKAGE_USR" ] ; then
61- cp -r /usr/lib/x86_64-linux-gnu/ /home/site/wwwroot/Package/usr/lib/
62- fi
63- PACKAGE_LIB="/home/site/wwwroot/Package/lib"
64- if [ -d "$PACKAGE_LIB" ] ; then
65- cp -r /lib/x86_64-linux-gnu/ /home/site/wwwroot/Package/lib/
66- fi
54+ echo "Package directory does not exist. Installing dependencies..."
55+ apt-get update && apt-get install -yq --no-install-recommends libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 libnss3 libgbm1
56+ mkdir -p /home/site/wwwroot/Package/usr/lib/x86_64-linux-gnu
57+ mkdir -p /home/site/wwwroot/Package/lib/x86_64-linux-gnu
58+ PACKAGE_USR="/home/site/wwwroot/Package/usr/lib/x86_64-linux-gnu"
59+ if [ -d "$PACKAGE_USR" ] ; then
60+ echo "Copying user libraries to package..."
61+ rsync -av /usr/lib/x86_64-linux-gnu/ /home/site/wwwroot/Package/usr/lib/x86_64-linux-gnu
62+ fi
6763fi
6864
65+ echo "Dependencies installation script completed."
66+
6967{% endhighlight %}
7068
7169![ Convert HTMLToPDF Azure Functions Step5] ( htmlconversion_images\ShellCommand.png )
@@ -145,11 +143,7 @@ public byte[] HtmlToPdfConvert(string htmlText)
145143 Bottom = 20
146144 }
147145 };
148- //Set command line arguments to run without sandbox.
149- settings.CommandLineArguments.Add("--no-sandbox");
150- settings.CommandLineArguments.Add("--disable-setuid-sandbox");
151-
152-
146+
153147 htmlConverter.ConverterSettings = settings;
154148
155149 // Convert HTML to PDF
0 commit comments