Skip to main content

I was wondering if there's an updated script on installing vlc on macOS Catalina machines. I have tried modifying older scripts with no luck. Any help would be appreciated. Thank you.

I just had it fail from the videolan.org website (2x, worked on the 3rd time). If you use one of the mirrors, the old any-app-template method should still work.


Hey just tested this one and it seemed to work just fine:

#!/bin/bash
temp=$TMPDIR$(uuidgen)
mkdir -p $temp/mount
curl https://vlc.freemirror.org/vlc/3.0.7.1/macosx/vlc-3.0.7.1.dmg > $temp/1.dmg
yes | hdiutil attach -noverify -nobrowse -mountpoint $temp/mount $temp/1.dmg
cp -r $temp/mount/*.app /Applications
hdiutil detach $temp/mount
rm -r $temp

Granted you may need to update the version.


#!/bin/sh
temp=$TMPDIR$(uuidgen)

mkdir -p $temp/mount

vlcVersion=`expr "$(curl "get.videolan.org/vlc/last/macosx/")" : '.*(vlc-.*.dmg)'`

curl -L get.videolan.org/vlc/last/macosx/$vlcVersion > $temp/vlc.dmg

yes | hdiutil attach -noverify -nobrowse -mountpoint $temp/mount $temp/vlc.dmg

cp -r $temp/mount/*.app /Applications

hdiutil detach $temp/mount

rm -r $temp

This is my current solution and its been working great!


Hi,

I tried both scripts and I keep getting this error message on the logs:

Script result: mkdir: D9C3A8D4-7870-4193-B2D8-9003F4986610/mount: Read-only file system
/Library/Application Support/JAMF/tmp/newvlc: line 4: D9C3A8D4-7870-4193-B2D8-9003F4986610/1.dmg: No such file or directory
hdiutil: attach failed - No such file or directory
cp: D9C3A8D4-7870-4193-B2D8-9003F4986610/mount/*.app: No such file or directory
hdiutil: detach failed - No such file or directory
rm: D9C3A8D4-7870-4193-B2D8-9003F4986610: No such file or directory


Try a mirror
https://ftp.osuosl.org/pub/videolan/vlc/3.0.8/macosx/vlc-3.0.8.dmg
https://mirror.csclub.uwaterloo.ca/vlc/vlc/3.0.8/macosx/vlc-3.0.8.dmg
https://mirrors.syringanetworks.net/videolan/vlc/3.0.8/macosx/vlc-3.0.8.dmg
https://mirror.clarkson.edu/videolan/vlc/3.0.8/macosx/vlc-3.0.8.dmg


@khunley I recommend opening a terminal on a desktop and just copy pasting the script line by line and seeing where you're getting the hiccup.

Just by looking at that output 1.dmg doesn't exist. Are you sure your script is downloading it as 1.dmg and not something else and then a later part is trying to call 1.dmg?


Here is another VLC install script (mine). I provide the current version (3.0.8) and current SHA256 checksum (422aaf37cd12cdc49f27a5f8fa9a16d287ea8ae8f451cedc8b7a2e0b5d39c068) as $4 and $5 variables.

#!/bin/bash

# Automatically download and install VLC

if [[ -z $4 ]]; then
  echo "Version not specified"
  exit 1
fi

# Variables
appName="VLC.app"
dmgName="vlc-$4.dmg"
dmgVolumePath="/Volumes/VLC media player"
downloadUrl="https://download.videolan.org/pub/videolan/vlc/$4/macosx"

# Start

appPath="/Applications/${appName}"

# List version
if [[ -d "${appPath}" ]]; then
  echo "${appName} version is $(defaults read "${appPath}"/Contents/Info.plist CFBundleShortVersionString)"
else
  echo "${appName} not installed"
fi

# Download DMG file into /tmp/
curl -s ${downloadUrl}/${dmgName} -o "/tmp/${dmgName}"

# Verify SHA256 checksum
if [[ $(shasum -a 256 "/tmp/${dmgName}" | awk '{print $1}') == "$5" ]]; then
  echo "Checksum verified"
else
  echo "Checksum verification failed"
  echo "Failed checksum is $(shasum -a 256 "/tmp/${dmgName}" | awk '{print $1}')"
  rm -f "/tmp/${dmgName}"
  exit 1
fi

# Mount DMG File
hdiutil attach "/tmp/${dmgName}" -nobrowse

# Check for successful download
if [[ ! -d "${dmgVolumePath}" ]]; then
    echo "Download unsuccessful"
    exit 1
fi

# Remove app if already installed
if [[ -d "${appPath}" ]]; then
    rm -R "${appPath}"
    echo "Removed existing copy of ${appName} from /Applications directory"
fi

# Copy application to /Applications/
cp -R "${dmgVolumePath}/${appName}" /Applications/

# Unmount DMG file
hdiutil detach "${dmgVolumePath}"

# Remove downloaded DMG file
rm -f "/tmp/${dmgName}"

# List version and exit with error code if not found
if [[ -d "${appPath}" ]]; then
  echo "${appName} version is $(defaults read "${appPath}"/Contents/Info.plist CFBundleShortVersionString)"
else
  echo "${appName} not installed"
  exit 1
fi

I just used Recipe Robot to make an autopkgr recipe for VLC, the app uses sparkle so AutoPkgr will always grab the latest version based on the sparkle feed.


@khunley funny thing, I just ran into a similar issue you were running into but on something unrelated.

You're getting a download issue because the script is trying to navigate to "/Library/Application Support/JAMF/" but the script is breaking because of the space in "Application Support"

Try this and tell me if it works as expected:

#!/bin/sh
temp=$TMPDIR$(uuidgen)
noMount=/Library/JAMF/tmp/$temp
mount=$noMount/mount
mkdir -p $mount

vlcVersion=`expr "$(curl "get.videolan.org/vlc/last/macosx/")" : '.*(vlc-.*.dmg)'`
curl -L get.videolan.org/vlc/last/macosx/$vlcVersion > $noMount/vlc.dmg

yes | hdiutil attach -noverify -nobrowse -mountpoint $mount $noMount/vlc.dmg

cp -r $mount/*.app /Applications

hdiutil detach $mount

rm -r $noMount

let me know if you need any more help.


@Gennaro I'm so sorry for the late reply on this. I finally tried your script and it worked perfectly! Thank you so much for the help on this!


@khunley funny thing, I just ran into a similar issue you were running into but on something unrelated.

You're getting a download issue because the script is trying to navigate to "/Library/Application Support/JAMF/" but the script is breaking because of the space in "Application Support"

Try this and tell me if it works as expected:

#!/bin/sh
temp=$TMPDIR$(uuidgen)
noMount=/Library/JAMF/tmp/$temp
mount=$noMount/mount
mkdir -p $mount

vlcVersion=`expr "$(curl "get.videolan.org/vlc/last/macosx/")" : '.*(vlc-.*.dmg)'`
curl -L get.videolan.org/vlc/last/macosx/$vlcVersion > $noMount/vlc.dmg

yes | hdiutil attach -noverify -nobrowse -mountpoint $mount $noMount/vlc.dmg

cp -r $mount/*.app /Applications

hdiutil detach $mount

rm -r $noMount

let me know if you need any more help.


Is there an updated version of this script available?


@khunley funny thing, I just ran into a similar issue you were running into but on something unrelated.

You're getting a download issue because the script is trying to navigate to "/Library/Application Support/JAMF/" but the script is breaking because of the space in "Application Support"

Try this and tell me if it works as expected:

#!/bin/sh
temp=$TMPDIR$(uuidgen)
noMount=/Library/JAMF/tmp/$temp
mount=$noMount/mount
mkdir -p $mount

vlcVersion=`expr "$(curl "get.videolan.org/vlc/last/macosx/")" : '.*(vlc-.*.dmg)'`
curl -L get.videolan.org/vlc/last/macosx/$vlcVersion > $noMount/vlc.dmg

yes | hdiutil attach -noverify -nobrowse -mountpoint $mount $noMount/vlc.dmg

cp -r $mount/*.app /Applications

hdiutil detach $mount

rm -r $noMount

let me know if you need any more help.


I think this is failing as there are now three variants in get.videolan.org/vlc/last/macosx/

  1. vlc-3.0.16-arm64.dmg
  2. vlc-3.0.16-intel64.dmg
  3. vlc-3.0.16-universal.dmg

So we need logic based on 'arch' to get the correct version or just grab the universal variant.

 

 


Any update on this script? I imagine that we would want to just go with the Universal installer so we don't have to maintain two policies?


Any update on this script? I imagine that we would want to just go with the Universal installer so we don't have to maintain two policies?


https://github.com/cwmcbrewster/Jamf_Scripts/blob/master/Install_VLC.sh

 

I provide the version as $4 and the checksum as $5. Currently that is 3.0.17.3 and cff4e9d41ced0e29f88b75cb683a8fd5c788a9492047390d2b8a3ca7e8e37456.


https://github.com/cwmcbrewster/Jamf_Scripts/blob/master/Install_VLC.sh

 

I provide the version as $4 and the checksum as $5. Currently that is 3.0.17.3 and cff4e9d41ced0e29f88b75cb683a8fd5c788a9492047390d2b8a3ca7e8e37456.


Is there a way to not have to specify a version and install whichever is current? If I left $4 and $5 empty, would that accomplish this?


Is there a way to not have to specify a version and install whichever is current? If I left $4 and $5 empty, would that accomplish this?


Try this. I made this version a while back, just haven't put it to use.

 

#!/bin/zsh # Automatically download and install VLC # Variables appName="VLC.app" appPath="/Applications/${appName}" appProcessName="VLC" dmgVolumePath="/Volumes/VLC media player" downloadUrl="https://get.videolan.org/vlc/last/macosx" # Try to obtain and validate dmgName dmgName=$(curl -LSs "http://get.videolan.org/vlc/last/macosx/" | grep -E '\\"vlc-.+universal\\.dmg\\"' | awk -F\\" '{print $2}') echo "DMG Name: ${dmgName}" if [[ ! ${dmgName} =~ '^vlc.+\\.dmg$' ]]; then echo "Failed to get DMG name" exit 1 fi cleanup () { if [[ -f "${tmpDir}/${dmgName}" ]]; then if rm -f "${tmpDir}/${dmgName}"; then echo "Removed file ${tmpDir}/${dmgName}" fi fi if [[ -d "${tmpDir}" ]]; then if rm -R "${tmpDir}"; then echo "Removed directory ${tmpDir}" fi fi if [[ -d "${dmgVolumePath}" ]]; then if hdiutil detach "${dmgVolumePath}" -quiet; then echo "Unmounted DMG" fi fi } createTmpDir () { if [ -z ${tmpDir+x} ]; then tmpDir=$(mktemp -d) echo "Temp dir set to ${tmpDir}" fi } processCheck () { if pgrep -x "${appProcessName}" > /dev/null; then echo "${appProcessName} is currently running" echo "Aborting install" cleanup exit 0 else echo "${appProcessName} not currently running" fi } tryDownload () { if curl -LSs "${downloadUrl}/${dmgName}" -o "${tmpDir}/${dmgName}"; then echo "Download successful" tryDownloadState=1 else echo "Download unsuccessful" tryDownloadCounter=$((tryDownloadCounter+1)) fi } versionCheck () { if [[ -d "${appPath}" ]]; then echo "${appName} version is $(defaults read "${appPath}/Contents/Info.plist" CFBundleShortVersionString)" versionCheckStatus=1 else echo "${appName} not installed" versionCheckStatus=0 fi } # Start # List version versionCheck # Make sure volume is not already mounted and unmount if needed if [[ -d "${dmgVolumePath}" ]]; then echo "${dmgVolumePath} already in use. Attempting to unmount" hdiutil detach "${dmgVolumePath}" fi # Download dmg file into tmp dir (60 second timeout) tryDownloadState=0 tryDownloadCounter=0 while [[ ${tryDownloadState} -eq 0 && ${tryDownloadCounter} -le 60 ]]; do processCheck createTmpDir tryDownload sleep 1 done # Check for successful download if [[ ! -f "${tmpDir}/${dmgName}" ]]; then echo "Download unsuccessful" cleanup exit 1 fi # Mount dmg file if hdiutil attach "${tmpDir}/${dmgName}" -nobrowse -quiet; then echo "Mounted DMG" else echo "Failed to mount DMG" cleanup exit 1 fi # Check for expected dmg path if [[ ! -d "${dmgVolumePath}" ]]; then echo "Could not locate ${dmgVolumePath}" cleanup exit 1 fi # Remove app if already installed if [[ -d "${appPath}" ]]; then if rm -R "${appPath}"; then echo "Removed existing ${appName} from /Applications directory" else echo "Failed to remove existing ${appName} from /Applications directory" cleanup exit 1 fi fi # Copy application to /Applications if cp -R "${dmgVolumePath}/${appName}" /Applications/; then echo "Copied ${appName} to /Applications directory" else echo "Failed to copy ${appName} to /Applications directory" fi # Remove tmp dir and downloaded dmg file cleanup # List version and exit with error code if not found versionCheck if [[ ${versionCheckStatus} -eq 0 ]]; then exit 1 fi

Try this. I made this version a while back, just haven't put it to use.

 

#!/bin/zsh # Automatically download and install VLC # Variables appName="VLC.app" appPath="/Applications/${appName}" appProcessName="VLC" dmgVolumePath="/Volumes/VLC media player" downloadUrl="https://get.videolan.org/vlc/last/macosx" # Try to obtain and validate dmgName dmgName=$(curl -LSs "http://get.videolan.org/vlc/last/macosx/" | grep -E '\\"vlc-.+universal\\.dmg\\"' | awk -F\\" '{print $2}') echo "DMG Name: ${dmgName}" if [[ ! ${dmgName} =~ '^vlc.+\\.dmg$' ]]; then echo "Failed to get DMG name" exit 1 fi cleanup () { if [[ -f "${tmpDir}/${dmgName}" ]]; then if rm -f "${tmpDir}/${dmgName}"; then echo "Removed file ${tmpDir}/${dmgName}" fi fi if [[ -d "${tmpDir}" ]]; then if rm -R "${tmpDir}"; then echo "Removed directory ${tmpDir}" fi fi if [[ -d "${dmgVolumePath}" ]]; then if hdiutil detach "${dmgVolumePath}" -quiet; then echo "Unmounted DMG" fi fi } createTmpDir () { if [ -z ${tmpDir+x} ]; then tmpDir=$(mktemp -d) echo "Temp dir set to ${tmpDir}" fi } processCheck () { if pgrep -x "${appProcessName}" > /dev/null; then echo "${appProcessName} is currently running" echo "Aborting install" cleanup exit 0 else echo "${appProcessName} not currently running" fi } tryDownload () { if curl -LSs "${downloadUrl}/${dmgName}" -o "${tmpDir}/${dmgName}"; then echo "Download successful" tryDownloadState=1 else echo "Download unsuccessful" tryDownloadCounter=$((tryDownloadCounter+1)) fi } versionCheck () { if [[ -d "${appPath}" ]]; then echo "${appName} version is $(defaults read "${appPath}/Contents/Info.plist" CFBundleShortVersionString)" versionCheckStatus=1 else echo "${appName} not installed" versionCheckStatus=0 fi } # Start # List version versionCheck # Make sure volume is not already mounted and unmount if needed if [[ -d "${dmgVolumePath}" ]]; then echo "${dmgVolumePath} already in use. Attempting to unmount" hdiutil detach "${dmgVolumePath}" fi # Download dmg file into tmp dir (60 second timeout) tryDownloadState=0 tryDownloadCounter=0 while [[ ${tryDownloadState} -eq 0 && ${tryDownloadCounter} -le 60 ]]; do processCheck createTmpDir tryDownload sleep 1 done # Check for successful download if [[ ! -f "${tmpDir}/${dmgName}" ]]; then echo "Download unsuccessful" cleanup exit 1 fi # Mount dmg file if hdiutil attach "${tmpDir}/${dmgName}" -nobrowse -quiet; then echo "Mounted DMG" else echo "Failed to mount DMG" cleanup exit 1 fi # Check for expected dmg path if [[ ! -d "${dmgVolumePath}" ]]; then echo "Could not locate ${dmgVolumePath}" cleanup exit 1 fi # Remove app if already installed if [[ -d "${appPath}" ]]; then if rm -R "${appPath}"; then echo "Removed existing ${appName} from /Applications directory" else echo "Failed to remove existing ${appName} from /Applications directory" cleanup exit 1 fi fi # Copy application to /Applications if cp -R "${dmgVolumePath}/${appName}" /Applications/; then echo "Copied ${appName} to /Applications directory" else echo "Failed to copy ${appName} to /Applications directory" fi # Remove tmp dir and downloaded dmg file cleanup # List version and exit with error code if not found versionCheck if [[ ${versionCheckStatus} -eq 0 ]]; then exit 1 fi

I will give it a go! Thank you!


Hey KHunley, 

 

This script worked for me, Talking Moose knows his stuff.  I created a script within Jamf and just copied and pasted Talking Moose script off of git hub.  Deployed it as a policy and worked like a champ. 

VLC Script