Skip to content

Instantly share code, notes, and snippets.

@ukos-git
Last active May 6, 2022 17:44
Show Gist options
  • Save ukos-git/5bb3564496b444e919c4ea2d3963a3ea to your computer and use it in GitHub Desktop.
Save ukos-git/5bb3564496b444e919c4ea2d3963a3ea to your computer and use it in GitHub Desktop.
install microsoft office 2013 pro
#!/bin/bash
check_wine() {
if ! wine --version | grep -e 'wine-2'
then
echo "consider installing wine-2.1"
apt-cache policy wine32 wine-development
exit 1
fi
}
check_root() {
if ! sudo -n /bin/true 2>/dev/null
then
echo super user is required for installation.
sudo /bin/true
fi
}
check_winbind() {
if ! command -v winbindd > /dev/null
then
check_root
sudo apt install winbind
fi
}
check_winetricks() {
if command -v winetricks > /dev/null
then
WINETRICKS_EXE=$(command -v winetricks)
else
WINETRICKS_EXE="/home/${USER}/Downloads/winetricks"
if [ ! -e "$WINETRICKS_EXE" ]; then
check_wget
wget https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks -O "$WINETRICKS_EXE"
fi
chmod u+x "$WINETRICKS_EXE"
fi
}
check_wget() {
if ! command -v guestmount > /dev/null
then
check_root
sudo apt install wget
fi
}
get_office() {
if [ ! -e ~/Downloads/office2013pro.img ]
then
check_wget
#link from https://www.askvg.com/direct-download-link-microsoft-office-2013-professional-plus-free-trial/
wget http://care.dlservice.microsoft.com/dl/download/2/9/C/29CC45EF-4CDA-4710-9FB3-1489786570A1/OfficeProfessionalPlus_x86_en-us.img -O ~/Downloads/office2013pro.img
fi
gnome-disk-image-mounter ~/Downloads/office2013pro.img
echo $?
}
check_requirements() {
check_wine
check_winbind
check_winetricks
}
add_to_path() {
cat > ${HOME}/bin/winword <<_EOF_
#!/bin/bash
wine "C:\Program Files\Microsoft Office\Office15\WINWORD.EXE"
_EOF_
chmod u+x ${HOME}/bin/winword
cat > ${HOME}/bin/excel <<_EOF_
#!/bin/bash
wine "C:\Program Files\Microsoft Office\Office15\EXCEL.EXE"
_EOF_
chmod u+x ${HOME}/bin/excel
cat > ${HOME}/bin/powerpoint <<_EOF_
#!/bin/bash
wine "C:\Program Files\Microsoft Office\Office15\POWERPNT.EXE"
_EOF_
chmod u+x ${HOME}/bin/powerpoint
}
winetricks_office2013() {
OFFICE_VERB=$(mktemp --tmpdir office2013XXX.verb)
OFFICE_VERB="/home/${USER}/Downloads/office2013pro.verb"
cat > "$OFFICE_VERB" <<'EOF'
w_metadata office2013pro apps \
title="Microsoft Office 2013 Professional" \
publisher="Microsoft" \
media="cd" \
file1="setup.exe" \
installed_file1="$W_PROGRAMS_X86_WIN/Microsoft Office/Office15/WINWORD.EXE"
load_office2013pro()
{
if ! command -v winbindd > /dev/null; then
w_warn "winbind is required"
fi
w_set_winver win7
w_call corefonts
w_call msxml6
w_call riched20
cat > "$W_TMP"/MaxVersionGL.reg <<_EOF_
REGEDIT4
[HKEY_CURRENT_USER\Software\Wine\Direct3D]
"MaxVersionGL"=dword:00030002
_EOF_
w_try_regedit "$W_TMP_WIN"\\MaxVersionGL.reg
#w_mount OFFICE15
#w_try "$WINE" "${W_ISO_MOUNT_LETTER}:${file1}"
}
EOF
set +e
WINEARCH=win32 wine wineboot
"$WINETRICKS_EXE" "$OFFICE_VERB"
EXITSTATUS=$?
set -e
if (($EXITSTATUS == 0)); then
echo Installation seems to be ok
exit 0
fi
}
check_requirements
winetricks_office2013
# work-around for img installation
if [ -z "$MOUNTPOINT" ]
then
# this is the hardcoded mountpoint from gnome-disk-utility
MOUNTPOINT="/media/${USER}/15.0.4420.10173"
fi
if [ ! -e "$MOUNTPOINT" ]
then
echo "manually call setup.exe after mounting or start script with MOUNTPOINT=/path/to/mount /path/to/script"
get_office
fi
wine "/media/${USER}/15.0.4420.10173/setup.exe"
winetricks_office2013
add_to_path
@ukos-git
Copy link
Author

@jojoamrni
Copy link

Sir, how do I install this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment