chore: fixed macos update script

This commit is contained in:
vladimir.kuznetsov 2025-01-02 13:40:55 +07:00
parent eb6c40f92a
commit 44082462b7
6 changed files with 35 additions and 46 deletions

View file

@ -8,22 +8,42 @@ rm -rf "$EXTRACT_DIR"
mkdir -p "$EXTRACT_DIR"
# Mount the DMG
hdiutil attach "$INSTALLER_PATH" -mountpoint "$EXTRACT_DIR/mounted_dmg" -nobrowse -quiet
MOUNT_POINT="$EXTRACT_DIR/mounted_dmg"
hdiutil attach "$INSTALLER_PATH" -mountpoint "$MOUNT_POINT"
if [ $? -ne 0 ]; then
echo "Failed to mount DMG"
exit 1
fi
# Copy the app to /Applications
cp -R "$EXTRACT_DIR/mounted_dmg/AmneziaVPN.app" /Applications/
if [ $? -ne 0 ]; then
echo "Failed to copy AmneziaVPN.app to /Applications"
hdiutil detach "$EXTRACT_DIR/mounted_dmg" -quiet
# Check if the application exists in the mounted DMG
if [ ! -d "$MOUNT_POINT/AmneziaVPN.app" ]; then
echo "Error: AmneziaVPN.app not found in the mounted DMG."
hdiutil detach "$MOUNT_POINT" #-quiet
exit 1
fi
# Run the application
echo "Running AmneziaVPN.app from the mounted DMG..."
open "$MOUNT_POINT/AmneziaVPN.app"
# Get the PID of the app launched from the DMG
APP_PATH="$MOUNT_POINT/AmneziaVPN.app"
PID=$(pgrep -f "$APP_PATH")
if [ -z "$PID" ]; then
echo "Failed to retrieve PID for AmneziaVPN.app"
hdiutil detach "$MOUNT_POINT"
exit 1
fi
# Wait for the specific PID to exit
echo "Waiting for AmneziaVPN.app to exit..."
while kill -0 "$PID" 2>/dev/null; do
sleep 1
done
# Unmount the DMG
hdiutil detach "$EXTRACT_DIR/mounted_dmg" -quiet
hdiutil detach "$EXTRACT_DIR/mounted_dmg"
if [ $? -ne 0 ]; then
echo "Failed to unmount DMG"
exit 1
@ -33,4 +53,4 @@ fi
rm "$INSTALLER_PATH"
echo "Installation completed successfully"
exit 0
exit 0

View file

@ -147,14 +147,13 @@ void UpdateController::runInstaller()
}
file.close();
QString t = installerPath;
#if defined(Q_OS_WINDOWS)
runWindowsInstaller(t);
runWindowsInstaller(installerPath);
#elif defined(Q_OS_MACOS)
runMacInstaller(t);
runMacInstaller(installerPath);
#elif defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
runLinuxInstaller(t);
runLinuxInstaller(installerPath);
#endif
} else {
if (reply->error() == QNetworkReply::NetworkError::OperationCanceledError

View file

@ -16,14 +16,6 @@ DrawerType2 {
expandedContent: Item {
implicitHeight: root.expandedHeight
Connections {
target: root
enabled: !GC.isMobile()
function onOpened() {
focusItem.forceActiveFocus()
}
}
Header2TextType {
id: header
anchors.top: parent.top
@ -32,6 +24,7 @@ DrawerType2 {
anchors.topMargin: 16
anchors.rightMargin: 16
anchors.leftMargin: 16
anchors.bottomMargin: 16
text: UpdateController.headerText
}
@ -46,9 +39,10 @@ DrawerType2 {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 48
anchors.topMargin: 16
anchors.rightMargin: 16
anchors.leftMargin: 16
anchors.bottomMargin: 16
HoverHandler {
enabled: parent.hoveredLink
@ -64,17 +58,11 @@ DrawerType2 {
}
}
Item {
id: focusItem
KeyNavigation.tab: updateButton
}
BasicButtonType {
id: updateButton
anchors.bottom: skipButton.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 16
anchors.bottomMargin: 8
anchors.rightMargin: 16
anchors.leftMargin: 16
@ -87,8 +75,6 @@ DrawerType2 {
PageController.showBusyIndicator(false)
root.close()
}
KeyNavigation.tab: skipButton
}
BasicButtonType {
@ -107,13 +93,11 @@ DrawerType2 {
textColor: "#D7D8DB"
borderWidth: 1
text: qsTr("Skip this version")
text: qsTr("Skip")
clickedFunc: function() {
root.close()
}
KeyNavigation.tab: focusItem
}
}
}

View file

@ -32,7 +32,5 @@ class IpcInterface
SLOT( bool enablePeerTraffic( const QJsonObject &configStr) );
SLOT( bool enableKillSwitch( const QJsonObject &excludeAddr, int vpnAdapterIndex) );
SLOT( bool updateResolvers(const QString& ifname, const QList<QHostAddress>& resolvers) );
SLOT( int mountDmg(const QString &path, bool mount) );
};

View file

@ -368,14 +368,3 @@ bool IpcServer::enablePeerTraffic(const QJsonObject &configStr)
#endif
return true;
}
int IpcServer::mountDmg(const QString &path, bool mount)
{
#ifdef Q_OS_MACOS
qDebug() << path;
auto res = QProcess::execute(QString("sudo hdiutil %1 %2").arg(mount ? "attach" : "unmount", path));
qDebug() << res;
return res;
#endif
return 0;
}

View file

@ -38,7 +38,6 @@ public:
virtual bool enableKillSwitch(const QJsonObject &excludeAddr, int vpnAdapterIndex) override;
virtual bool disableKillSwitch() override;
virtual bool updateResolvers(const QString &ifname, const QList<QHostAddress> &resolvers) override;
virtual int mountDmg(const QString &path, bool mount) override;
private:
int m_localpid = 0;