Improved installation scripts

Updated Linux/BSD scripts.
Added Mac and Windows scripts.
This commit is contained in:
Valentino Orlandi 2022-08-25 20:37:01 +02:00
parent f13480de49
commit 25cb10db41
Signed by: elB4RTO
GPG Key ID: 1719E976DB2D4E71
6 changed files with 440 additions and 3 deletions

122
build_install.bat Normal file
View File

@ -0,0 +1,122 @@
:: Store the actual path
SET actual_path=%CD%
:: Get the path of LogDoctor-git's folder and move in
SET docdir=%~dp1
cd "%docdir%"
:: Check the existence of a previous executable file
IF EXIST C:\ProgramFiles\LogDoctor\ {
ECHO "Warning: the path C:\ProgramFiles\LogDoctor\ already exists"
SET /P agree="IF you choose to continue, the actual content will be overwritten\nContinue? [y/n] : "
IF "%agree%"!="y" {
IF "%agree%"!="Y" {
EXIT /B
}
}
}
:: Start the compilation process
ECHO "Starting compilation process"
:: Make a build folder
mkdir build && cd build
:: Prepare the cmake files
cmake ../logdoctor -DCMAKE_BUILD_TYPE=MinSizeRel
IF ERRORLEVEL 1 {
:: an error occured during preparation
ECHO "Error: failed to prepare cmake files"
EXIT /B
}
:: Build the project
cmake --build ./ --target all
IF ERRORLEVEL 1 {
:: an error occured during compilation
ECHO "Error: failed to compile"
EXIT /B
}
:: Compilation finished
ECHO "Compilation finished"
:: Start installing LogDoctor
ECHO "Starting installation process"
cd ../installation_stuff/
IF EXIST %USERPROFILE%\AppData\Local\LogDoctor {
IF EXIST %USERPROFILE%\AppData\Local\LogDoctor\logdoctor.conf {
:: A configuration file already exists
ECHO "Warning: a configuration file already exists"
SET /P agree="IF you choose 'YES' the current file will be overwritten\nIF you choose 'NO' the current file will be kept\nOverwrite? [y/n] : "
IF "%agree%"!="y" {
IF "%agree%"!="Y" {
EXIT /B
}
}
copy logdoctor.conf %USERPROFILE%\AppData\Local\LogDoctor\
IF ERRORLEVEL 1 {
:: an error occured during compilation
ECHO "Error: failed to copy configuration file"
EXIT /B
}
copy logdocdata\* %USERPROFILE%\AppData\Local\LogDoctor\
IF ERRORLEVEL 1 {
:: an error occured during compilation
ECHO "Error: failed to copy LogDoctor's data"
EXIT /B
}
}
} ELSE {
mkdir %USERPROFILE%\AppData\Local\LogDoctor
IF ERRORLEVEL 1 {
ECHO "Error: failed to create directory: %USERPROFILE%\AppData\Local\LogDoctor"
EXIT /B
}
copy logdoctor.conf %USERPROFILE%\AppData\Local\LogDoctor\logdoctor.conf
IF ERRORLEVEL 1 {
ECHO "Error: failed to copy configuration file"
EXIT /B
}
copy logdocdata\* %USERPROFILE%\AppData\Local\LogDoctor\
IF ERRORLEVEL 1 {
ECHO "Error: failed to copy LogDoctor's data"
EXIT /B
}
}
IF NOT EXIST C:\ProgramFiles\LogDoctor\ {
runas /user:administrator mkdir C:\ProgramFiles\LogDoctor
IF ERRORLEVEL 1 {
ECHO "Error: failed to create directory: C:\ProgramFiles\LogDoctor"
EXIT /B
}
}
runas /user:administrator copy LogDoctor.exe C:\ProgramFiles\LogDoctor\
IF ERRORLEVEL 1 {
ECHO "Error: failed to copy the executable"
EXIT /B
}
runas /user:administrator copy ./logdoctor.svg C:\ProgramFiles\LogDoctor\LogDoctor.svg
IF ERRORLEVEL 1 {
ECHO "Error: failed to copy the icon"
EXIT /B
}
:: Installation finished
ECHO "Installation finished"
cd "%actual_path%"

View File

@ -143,7 +143,7 @@ if [[ "$?" != "0" ]]
cp --no-preserve=all ./logdoctor ./logdoctor.copy
chmod +x ./logdoctor.copy
chmod 755 ./logdoctor.copy
sudo mv ./logdoctor.copy /usr/bin/logdoctor
if [[ "$?" != "0" ]]
then

149
build_install_MAC.sh Normal file
View File

@ -0,0 +1,149 @@
#!/bin/bash
# Store the actual path
actual_path=$(pwd)
# Get the path of LogDoctor-git's folder and move in
docdir="$(dirname $(realpath $0))"
cd "$docdir"
# Check cmake availability
if [[ $(which cmake) =~ ^/ ]]
then
$()
else
echo "Error: Cmake is not installed"
exit
fi
# Check the existence of a previous executable file
if [ -e /Applications/LogDoctor.app ]
then
while true;
do
echo "Warning: the path /Applications/LogDoctor.app already exists"
printf "If you choose to continue, the actual content will be overwritten\nContinue? [y/n] : "
read agree
case "$agree"
in
"y" | "Y")
printf "\n"
break
;;
*)
exit
;;
esac
done
fi
# Start the compilation process
echo "Starting compilation process"
# Make a build folder
mkdir build && cd build
# Prepare the cmake files
cmake ../logdoctor -DCMAKE_BUILD_TYPE=MinSizeRel
if [[ "$?" != "0" ]]
then
# an error occured during preparation
echo "Error: failed to prepare cmake files"
exit
fi
# Build the project
cmake --build ./ --target all
if [[ "$?" == "0" ]]
then
# compiled succesfully
echo "Done compiling"
chmod 755 ./LogDoctor
mv LogDoctor ../installation_stuff/LogDoctor.app/bin/
else
# an error occured during compilation
echo "Error: failed to compile"
exit
fi
# Compilation finished
wait
echo "Compilation finished"
# Start installing LogDoctor
echo "Starting installation process"
cd ../installation_stuff/
if [ -e ~/Lybrary/Preferences/LogDoctor ]
then
if [ -e ~/Lybrary/Preferences/LogDoctor/logdoctor.conf ]
then
# A configuration file already exists
while true;
do
echo "Warning: a configuration file already exists"
printf "If you choose 'YES' the current file will be overwritten\nIf you choose 'NO' the current file will be kept\nOverwrite? [y/n] : "
read agree
case "$agree"
in
"y" | "Y")
printf "\n"
cp --no-preserve=all ./logdoctor.conf ~/Lybrary/Preferences/LogDoctor/
if [[ "$?" != "0" ]]
then
# an error occured during compilation
echo "Error: failed to copy configuration file"
exit
fi
break
;;
*)
break
;;
esac
done
fi
else
mkdir -p ~/Lybrary/Preferences/LogDoctor
if [[ "$?" != "0" ]]
then
echo "Error: failed to create directory: ~/Lybrary/Preferences/LogDoctor"
exit
fi
cp --no-preserve=all ./logdoctor.conf ~/Lybrary/Preferences/LogDoctor/
if [[ "$?" != "0" ]]
then
echo "Error: failed to copy configuration file"
exit
fi
fi
if [ ! -e ~/Lybrary/Application Support/LogDoctor ]
else
mkdir -p ~/Lybrary/Application Support/LogDoctor
if [[ "$?" != "0" ]]
then
echo "Error: failed to create directory: ~/Lybrary/Application Support/LogDoctor"
exit
fi
cp -r --no-preserve=all ./logdocdata/help ~/Lybrary/Application Support/LogDoctor/
if [[ "$?" != "0" ]]
then
echo "Error: failed to copy LogDoctor's data"
exit
fi
cp --no-preserve=all ./LogDoctor.app ./LogDoctor.app.copy
sudo mv ./LogDoctor.app.copy /Applications/LogDoctor.app
if [[ "$?" != "0" ]]
then
echo "Error: failed to copy the executable"
exit
fi
# Installation finished
echo "Installation finished"
cd "$actual_path"

73
build_update.bat Normal file
View File

@ -0,0 +1,73 @@
:: Store the actual path
SET actual_path=%CD%
:: Get the path of LogDoctor-git's folder and move in
SET docdir=%~dp1
cd "%docdir%"
:: Check the existence of a previous executable file
IF NOT EXIST C:\ProgramFiles\LogDoctor\ {
ECHO "Warning: no previous installation detected, please run the installation script instead"
EXIT /B /B
}
:: Start the compilation process
ECHO "Starting compilation process"
:: Make a build folder
mkdir build && cd build
:: Prepare the cmake files
cmake ../logdoctor -DCMAKE_BUILD_TYPE=MinSizeRel
IF ERRORLEVEL 1 {
:: an error occured during preparation
ECHO "Error: failed to prepare cmake files"
EXIT /B /B
}
:: Build the project
cmake --build ./ --target all
IF ERRORLEVEL 1 {
:: an error occured during compilation
ECHO "Error: failed to compile"
EXIT /B /B
}
:: Compilation finished
ECHO "Compilation finished"
:: Start installing LogDoctor
ECHO "Starting update process"
cd ../installation_stuff/
IF NOT EXIST %USERPROFILE%\AppData\Local\LogDoctor {
mkdir %USERPROFILE%\AppData\Local\LogDoctor
IF ERRORLEVEL 1 {
ECHO "Error: failed to create directory: %USERPROFILE%\AppData\Local\LogDoctor"
EXIT /B
}
}
copy logdocdata\* %USERPROFILE%\AppData\Local\LogDoctor\
IF ERRORLEVEL 1 {
ECHO "Error: failed to copy LogDoctor's data"
}
runas /user:administrator copy LogDoctor.exe C:\ProgramFiles\LogDoctor\
IF ERRORLEVEL 1 {
ECHO "Error: failed to copy the executable"
EXIT /B
}
runas /user:administrator copy ./logdoctor.svg C:\ProgramFiles\LogDoctor\LogDoctor.svg
IF ERRORLEVEL 1 {
ECHO "Error: failed to copy the icon"
EXIT /B
}
:: Update finished
ECHO "Update finished"
cd "%actual_path%"

View File

@ -20,6 +20,7 @@ if [[ $(which cmake) =~ ^/ ]]
if [ ! -e /usr/bin/logdoctor ]
then
echo "Warning: no previous installation detected, please run the installation script instead"
exit
fi
# Start the compilation process
@ -60,7 +61,7 @@ cd ../installation_stuff/
if [ ! -e ~/.local/share/LogDoctor ]
else
then
mkdir -p ~/.local/share/LogDoctor
if [[ "$?" != "0" ]]
then
@ -93,7 +94,7 @@ if [[ "$?" != "0" ]]
cd ../build
cp --no-preserve=all ./logdoctor ./logdoctor.copy
chmod +x ./logdoctor.copy
chmod 755 ./logdoctor.copy
sudo mv ./logdoctor.copy /usr/bin/logdoctor
if [[ "$?" != "0" ]]
then

92
build_update_MAC.sh Normal file
View File

@ -0,0 +1,92 @@
#!/bin/bash
# Store the actual path
actual_path=$(pwd)
# Get the path of LogDoctor-git's folder and move in
docdir="$(dirname $(realpath $0))"
cd "$docdir"
# Check cmake availability
if [[ $(which cmake) =~ ^/ ]]
then
$()
else
echo "Error: Cmake is not installed"
exit
fi
# Check the existence of a previous executable file
if [ ! -e /Applications/LogDoctor.app ]
then
echo "Warning: no previous installation detected, please run the installation script instead"
exit
fi
# Start the compilation process
echo "Starting compilation process"
# Make a build folder
mkdir build && cd build
# Prepare the cmake files
cmake ../logdoctor -DCMAKE_BUILD_TYPE=MinSizeRel
if [[ "$?" != "0" ]]
then
# an error occured during preparation
echo "Error: failed to prepare cmake files"
exit
fi
# Build the project
cmake --build ./ --target all
if [[ "$?" == "0" ]]
then
# compiled succesfully
echo "Done compiling"
chmod 755 ./LogDoctor
mv LogDoctor ../installation_stuff/LogDoctor.app/bin/
else
# an error occured during compilation
echo "Error: failed to compile"
exit
fi
# Compilation finished
wait
echo "Compilation finished"
# Start installing LogDoctor
echo "Starting update process"
cd ../installation_stuff/
if [ ! -e ~/"Lybrary/Application Support/LogDoctor" ]
then
mkdir -p ~/"Lybrary/Application Support/LogDoctor"
if [[ "$?" != "0" ]]
then
echo "Error: failed to create directory: '~/Lybrary/Application Support/LogDoctor'"
exit
fi
cp -r --no-preserve=all ./logdocdata/help ~/"Lybrary/Application Support/LogDoctor"
if [[ "$?" != "0" ]]
then
echo "Error: failed to copy LogDoctor's data"
exit
fi
cd ../build
cp --no-preserve=all ./LogDoctor.app ./LogDoctor.app.copy
sudo mv ./LogDoctor.app.copy /Applications/LogDoctor.app
if [[ "$?" != "0" ]]
then
echo "Error: failed to copy the executable"
exit
fi
# Update finished
echo "Update finished"
cd "$actual_path"