summaryrefslogtreecommitdiff
path: root/ar/.local/bin/iwaf
blob: 89b10b2f24b3a3f0afa0047f3a89d2bfde38ee64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/sh

_check_wine() {
  wine_exe="$1"

  ls "${wine_exe}" >/dev/null 2>/dev/null
}

_exec_wine() {
  wine_exe="$1"
  wine_exe2="${wine_exe%/*}"
  wine_exe2="${wine_exe2}/SOOPStreamer.exe"

  echo 'Executing Soop...'
  wine "${wine_exe}"
  # wine "${wine_exe2}"
}

_install_wine() {
  # Source URL for the SOOPStreamer installer
  src_url='https://creatorup.sooplive.co.kr/SOOPStreamer_installer.exe'

  # Create a temporary file for the installer
  dst_file="$(mktemp)"
  # Ensure the temporary file is removed after the script finishes
  trap 'rm -f "$dst_file"' EXIT

  # Set a temporary HOME for the Wine process to avoid conflicts
  home_origin="$HOME"
  home_patch="$WINEPREFIX/tmp"
  export HOME="$home_patch"

  # Download the installer
  echo 'Downloading SOOP Streamer installer...'
  curl -s "$src_url" -o "$dst_file" || {
    echo "Failed to download installer!"
    exit 1
  }

  # Initialize Wine environment with win32 architecture
  echo 'Initializing Wine environment...'
  wineboot >/dev/null 2>&1

  # Check if winetricks is installed, if not, install it
  if ! command -v winetricks >/dev/null; then
    sudo pacman --noconfirm --needed -S winetricks || {
      echo "Failed to install winetricks!"
      exit 1
    }
  fi

  # Install necessary libraries via winetricks
  echo "Installing required libraries via winetricks..."
  if ! winetricks -q mfc42 vcrun2008; then
    echo "Failed to install required libraries!"
    exit 1
  fi

  # Run the SOOP Streamer installer without sudo
  echo 'Running the SOOP Streamer installer...'
  wine "$dst_file" /S >/dev/null 2>&1 && success=true || success=false

  # Clean up temporary Wine HOME directory
  echo 'Cleaning up...'
  rm -rf "$home_patch"

  # Restore original HOME and WINEARCH variables
  export HOME="$home_origin"

  # Check success status and print the result
  if $success; then
    echo 'Installation completed successfully.'
  else
    echo 'Installation failed!'
  fi
}

# Define a main function
main() {
  # Configure environment variables
  export LANG='en_US.UTF-8'
  export LC_ALL='en_US.UTF-8'
  export WINEARCH='win32'
  export WINEPREFIX="${WINEPREFIX:-${XDG_DATA_HOME:-${HOME}/.local/share}/wine}/soop"

  # Install
  wine_exe="${WINEPREFIX}/drive_c/users/$(whoami)/AppData/Local/SOOP/SOOPPackage.exe"
  if ! _check_wine "${wine_exe}"; then
    _install_wine "${wine_exe}"
  fi

  # Exec
  _exec_wine "${wine_exe}"
}

main