-
Notifications
You must be signed in to change notification settings - Fork 8
/
openfunscripter_setup_linux.sh
executable file
·124 lines (96 loc) · 3.57 KB
/
openfunscripter_setup_linux.sh
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
# Description: Installer for OFS + MTFG
arg1="$1"
if [ "$EUID" -eq 0 ]; then
echo "ERROR: You can not run this script with sudo!!"
exit 1
fi
echo "install required packages"
if command -v apt; then
# debian based distro:
sudo apt install -y curl
echo "Install OFS AppImage dependencies"
sudo apt install -y fuse
if ! command -v nix; then
sh <(curl -L https://nixos.org/nix/install) --daemon --yes
fi
fi
if [ -f /etc/profile.d/nix.sh ]; then
. /etc/profile.d/nix.sh
fi
if [ -f /home/$USER/.nix-profile/etc/profile.d/nix.sh ]; then
. /home/$USER/.nix-profile/etc/profile.d/nix.sh
fi
if ! command -v nix; then
echo "This installer require the package manager nix"
exit 1
fi
if [ ! -f ~/.config/nix/nix.conf ]; then
mkdir -p ~/.config/nix
echo "experimental-features = nix-command flakes" > ~/.config/nix/nix.conf
sudo systemctl restart nix-daemon.service
fi
OFS_APP_DIR="$HOME/.local/share/OFS/application"
OFS_EXTENSION_DIR="$HOME/.local/share/OFS/OFS3_data/extensions"
ofs_appimage_download_url=$(curl -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/OpenFunscripter/OFS/releases/latest | grep -Eo "https://.*64x.*AppImage")
echo "OFS AppImage Download URL: $ofs_appimage_download_url"
mkdir -p $OFS_APP_DIR/bin/data
rm -rf $OFS_APP_DIR/bin/OpenFunscripter
wget -c "$ofs_appimage_download_url" -O $OFS_APP_DIR/bin/OpenFunscripter
wget -c https://raw.githubusercontent.com/OpenFunscripter/OFS/master/data/logo64.png -O $OFS_APP_DIR/bin/data/logo64.png
chmod +x $OFS_APP_DIR/bin/OpenFunscripter
echo ">> Install ofs extension"
mkdir -p "$OFS_EXTENSION_DIR/MTFG"
pushd "$OFS_EXTENSION_DIR/MTFG"
if [ ! -d "$OFS_EXTENSION_DIR/MTFG/Python-Funscript-Editor/.git" ]; then
git clone https://github.com/michael-mueller-git/Python-Funscript-Editor.git
fi
pushd $OFS_EXTENSION_DIR/MTFG/Python-Funscript-Editor
echo "Update MTFG"
git reset --hard HEAD
git clean -fd
git remote prune origin
git checkout main
git fetch --prune
git pull
if [ "$arg1" != "--latest" ]; then
echo "Checkout latest MTFG release"
git checkout $(git describe --tags `git rev-list --tags --max-count=1`)
else
echo "Use latest git commit (only for developers!)"
# if git branch -a | grep -q "next" ; then
# echo "Switch to 'next' branch"
# git checkout next
# git pull
# fi
fi
echo "build nix environment"
nix develop --command sleep 1
popd
cp -fv "$OFS_EXTENSION_DIR/MTFG/Python-Funscript-Editor/assets/ffmpeg" \
"$OFS_EXTENSION_DIR/MTFG/Python-Funscript-Editor/funscript_editor/data/ffmpeg"
cp -fv "$OFS_EXTENSION_DIR/MTFG/Python-Funscript-Editor/contrib/Installer/assets/main.lua" \
"$OFS_EXTENSION_DIR/MTFG/main.lua"
cp -fv "$OFS_EXTENSION_DIR/MTFG/Python-Funscript-Editor/contrib/Installer/assets/json.lua" \
"$OFS_EXTENSION_DIR/MTFG/json.lua"
if [ ! -e ~/.local/bin/OpenFunscripter ]; then
mkdir -p ~/.local/bin
ln -s `realpath $OFS_APP_DIR`/bin/OpenFunscripter ~/.local/bin/OpenFunscripter
fi
mkdir -p ~/.local/share/applications
cat >~/.local/share/applications/OpenFunscripter.desktop <<EOL
[Desktop Entry]
Type=Application
Name=OpenFunscripter
Exec=`realpath $OFS_APP_DIR`/bin/OpenFunscripter
Comment=OpenFunscripter
StartupWMClass=OpenFunscripter
Icon=`realpath $OFS_APP_DIR`/bin/data/logo64.png
EOL
echo -e "\n"
echo "Installation Completed"
if [ "$arg1" = "--latest" ]; then
echo "WARNING: you have install the latest application code"
fi
# When nix was installed with this scrip we need an reboot to work
echo "You may need to restart you computer to get MTFG working"