Install/update VLC

greatkemo
Contributor II

@dan.kubley this is a similar script to yours I wrote, but allows me to get the latest version.

Hope it helps

#!/bin/bash

# script to update vlc
find /Volumes -type d -name *vlc* -maxdepth 1 -exec hdiutil detach -quiet {} ;
if [[ -e "/tmp/vlc.dmg" ]]; then
    rm "/tmp/vlc.dmg"
fi

# download and mount VLC
appName=`curl -s http://mirror.rasanegar.com/videolan/vlc/last/macosx/ | perl -pe 's/.*(vlc-.*dmg).*./$1/' | grep "vlc-" | tail -n1`
appURL="http://mirror.rasanegar.com/videolan/vlc/last/macosx/$appName"
curl -Lo "/tmp/vlc.dmg" "$appURL" --silent
hdiutil attach "/tmp/vlc.dmg" -nobrowse -quiet

# Install VLC
appVol=`find /Volumes -type d -name *vlc* -maxdepth 1`
ditto -rsrc "$appVol/VLC.app" "/Applications/VLC.app"
chown -R root:wheel "/Applications/VLC.app"
chmod -R 755 "/Applications/VLC.app"
sleep 3
hdiutil detach "$appVol" -quiet
sleep 3
rm "/tmp/vlc.dmg"
sleep 1
open "/Applications/VLC.app" &

exit 0
13 REPLIES 13

mecklind
New Contributor III

Works perfect, thank you!

MattP
New Contributor

This script works for me but it's also grabbing one version behind the latest release. It's currently installing 3.0.4 but if I manually go to the URL in the script it shows that 3.0.7.1 is the latest.

cedric67
New Contributor II

Hi,
I modified the url http://mirror.rasanegar.com/videolan/vlc/last/macosx/ which is down
by https://get.videolan.org/vlc/3.0.8/macosx/
and it doesn't work

I have this error :
Executing Policy TEST Mise à jour VLC
Running script Mise à jour VLC...
Script exit code: 0
Script result: ditto: can't get real path for source '/VLC.app'

Do you know why please ?

moritzZ_
New Contributor

Hi,
try to change the following lines:

URL to: https://get.videolan.org/vlc/last/macosx/
variable appVol vlc to VLC
appVol=`find /Volumes -type d -name VLC -maxdepth 1`

optional:
rm -f "/tmp/vlc.dmg"

cedric67
New Contributor II

I did for this line URL to: https://get.videolan.org/vlc/last/macosx/
I didn't for the others but i tryed an other script which do work :)

It's this one :

!/bin/bash

mkdir /tmp/downloads
cd /tmp/downloads

Installing VLC Player

CurrentVLC=$(curl "https://get.videolan.org/vlc/last/macosx/" | grep .dmg | grep -v webplugin | grep -v md5 | grep -v sha1 | grep -v sha256 | awk '{print $2}' | awk -F ">" '{print $2}' | tr -d "</a")

curl -L -o vlc.dmg https://get.videolan.org/vlc/last/macosx/$CurrentVLC

hdiutil mount -nobrowse vlc.dmg -mountpoint /Volumes/vlc
rsync -vaz /Volumes/vlc/VLC.app/ /Applications/VLC.app
hdiutil unmount "/Volumes/vlc"
rm vlc.dmg
rm -rf /tmp/downloads

Inspired from GetMacApps.com

rhooper
Contributor III

@cedric67 I used your script, But It does not install the VLC app... maybe.
Instead I am getting the following app installed, which launces nothing. 79882c1c640040c1af839e934db54a48
I looked at the info of this app, but it still has no information. Any ideas?
Some devices have 2.2.4 and we are attempting to update those devices with 3.0.8, while others have nothing installed. For those devices, I created a new 3.0.8 pkg using JAMF Composer, but that fails with an error about the signature. Both Catalina and Mojave OS and multiple devices.
Any help is much appreciated.

bmee
Contributor

This is what we used and set it to run once a mount on all device that had VLC installed.

#!/bin/bash

mkdir /tmp/downloads
cd /tmp/downloads

# Installing VLC Player
CurrentVLC=$(curl "http://get.videolan.org/vlc/last/macosx/" | grep .dmg | grep -v webplugin | grep -v md5 | grep -v sha1 | grep -v sha256 | awk '{print $2}' | awk -F ">" '{print $2}' | tr -d "</a")

curl -L -o vlc.dmg http://get.videolan.org/vlc/last/macosx/$CurrentVLC

hdiutil mount -nobrowse vlc.dmg -mountpoint /Volumes/vlc
rsync -vaz /Volumes/vlc/VLC.app/ /Applications/VLC.app
hdiutil unmount "/Volumes/vlc"
rm vlc.dmg
rm -rf /tmp/downloads

rhooper
Contributor III

So I tweaked the script above and it is now working without fail.
!/bin/bash
mkdir /tmp/downloads
cd /tmp/downloads

Installing VLC Player
*CurrentVLC=$(curl "https://get.videolan.org/vlc/last/macosx/" | grep .dmg | grep -v webplugin | grep -v md5 | grep -v sha1 | grep -v sha256 | awk '{print $2}' | awk -F ">" '{print $2}' | tr -d "</a")

curl -L -o vlc.dmg https://get.videolan.org/vlc/last/macosx/$CurrentVLC
rm -rf /Applications/VLC.app

hdiutil mount -nobrowse vlc.dmg -mountpoint /Volumes/vlc
rsync -vaz /Volumes/vlc/VLC.app/ /Applications/VLC.app
sleep 10
hdiutil unmount "/Volumes/vlc"

rm vlc.dmg

rm -rf /tmp/downloads*

See below for changes.
sleep 20 to allow the dmg to load completely.
rm - rf /Applications/VLC.app - which removes the Application before it is reloaded
Commented out rm vlc.dmg - more simple to delete the entire folder /tmp/downloads*

These changes seemed to work on several different devices with Mojave and Catalina. If the device did not have the VLC app it installed it, if it did have any older VLC apps it updated them. Best of all VLC now works great!
Thanks for the great script @cedric67

rhooper
Contributor III

Once again it is failing the install and update to VLC.
It is running through the script in like 3 seconds. Nothing noted in the install logs. While it was executing I tried to go to /tmp/downloads/ it does not locate any such folder. The script is in Shell. It does not appear to be creating the folder, therefore it is skipping a load of steps and errors out. JAMF Log> see the image.
43593aa31bad4aa1b4cff89a8c8cbfa4
Details do not reveal much, see image
/var/log/install.log says nothing of the script running.

ABigRock
New Contributor III

@bmee we have been using your scrip and it was working great but it has now stopped. Is it still working for you or do you happen to have an update for it? Here is what this log is showing: 

VLC Installer Log.png

mgeorgecv
New Contributor III

I made some changes:

#!/bin/bash
mkdir /tmp/downloads
cd /tmp/downloads

#Installing VLC Player
CurrentVLC=$(curl "https://get.videolan.org/vlc/last/macosx/" | grep "universal.dmg<" | /usr/bin/sed -e 's/<[^>][^>]*>//g' | /usr/bin/awk '{print $1}')

curl -L -o vlc.dmg https://get.videolan.org/vlc/last/macosx/$CurrentVLC

hdiutil mount -nobrowse vlc.dmg -mountpoint /Volumes/vlc
rsync -vaz /Volumes/vlc/VLC.app/ /Applications/VLC.app
sleep 20
hdiutil unmount "/Volumes/vlc"

rm -rf /tmp/downloads*

I also created specific version for Intel and Arm:

Arm64:

#!/bin/bash
mkdir /tmp/downloads
cd /tmp/downloads

#Installing VLC Player
CurrentVLC=$(curl "https://get.videolan.org/vlc/last/macosx/" | grep "arm64.dmg<" | /usr/bin/sed -e 's/<[^>][^>]*>//g' | /usr/bin/awk '{print $1}')

curl -L -o vlc.dmg https://get.videolan.org/vlc/last/macosx/$CurrentVLC

hdiutil mount -nobrowse vlc.dmg -mountpoint /Volumes/vlc
rsync -vaz /Volumes/vlc/VLC.app/ /Applications/VLC.app
sleep 20
hdiutil unmount "/Volumes/vlc"

rm -rf /tmp/downloads*

Intel64:

#!/bin/bash
mkdir /tmp/downloads
cd /tmp/downloads

#Installing VLC Player
CurrentVLC=$(curl "https://get.videolan.org/vlc/last/macosx/" | grep "intel64.dmg<" | /usr/bin/sed -e 's/<[^>][^>]*>//g' | /usr/bin/awk '{print $1}')

curl -L -o vlc.dmg https://get.videolan.org/vlc/last/macosx/$CurrentVLC

hdiutil mount -nobrowse vlc.dmg -mountpoint /Volumes/vlc
rsync -vaz /Volumes/vlc/VLC.app/ /Applications/VLC.app
sleep 20
hdiutil unmount "/Volumes/vlc"

rm -rf /tmp/downloads*

mgeorgecv
New Contributor III

I also created a script for an extension attribute:

#!/bin/bash

CurrentVLC=$(curl "https://get.videolan.org/vlc/last/macosx/" | grep "universal.dmg<" | /usr/bin/sed -e 's/<[^>][^>]*>//g' | /usr/bin/awk '{print $1}' | tr -d '[a-z]' | sed 's/..$//' | cut -c 2-)
if [ -d /Applications/VLC.app ]; then
VLCversion=$( sudo defaults read /Applications/VLC.app/Contents/info.plist CFBundleVersion )
VLCcheck=$VLCversion
else
VLCcheck="Notinstalled"
fi
if [ "$VLCcheck" == "$CurrentVLC" ]; then #Is VLC up to date?
    result="VLCuptoDate"
else result="VLCnotuptoDate"
fi
echo "<result>$result</result>"

mgeorgecv
New Contributor III

I then created Smart Groups and Policies to install the correct version on computers that were not up to date:

2022-01-10 15_13_39-Smart Computer Groups.png