-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
115 lines (86 loc) · 3.43 KB
/
install.sh
File metadata and controls
115 lines (86 loc) · 3.43 KB
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
#!/bin/bash
#!/bin/bash
# Define variables
REPO_URL="https://api.github.com/repos/Hanysabeh/YAS-pedistrain-camera/releases/latest"
DOWNLOAD_DIR="/opt/YAS-pedistrain-camera"
SERVICE_NAME="YAS-pedistrain-camera"
PACKAGE_NAME="YAS-pedistrain-camera-R2.tar.gz"
PYTHON_VERSION="3.10"
# Function to remove problematic repositories
remove_problematic_repos() {
sudo rm -f /etc/apt/sources.list.d/google-chrome.list
sudo rm -f /etc/apt/sources.list.d/google.list
sudo apt-get update
}
# Function to install dependencies
install_dependencies() {
sudo apt-get update
sudo apt-get install -y curl jq wget tar python3 python3-pip python3-venv
}
# Function to install Python
install_python() {
if ! command -v python3 &> /dev/null; then
echo "Python3 not found. Installing Python $PYTHON_VERSION..."
sudo apt-get install -y python$PYTHON_VERSION python3-pip
else
echo "Python3 is already installed."
fi
}
# Remove problematic repositories
remove_problematic_repos
# Create download directory if it doesn't exist
mkdir -p $DOWNLOAD_DIR
# Install dependencies
install_dependencies
# Download the latest release archive
DOWNLOAD_URL=$(curl -s $REPO_URL | jq -r '.assets[] | select(.name | endswith("tar.gz")) | .browser_download_url')
if [ -z "$DOWNLOAD_URL" ]; then
echo "Failed to retrieve the download URL. Please check your internet connection and try again."
exit 1
fi
wget -O $DOWNLOAD_DIR/$PACKAGE_NAME $DOWNLOAD_URL
# Verify the download
if [ ! -f $DOWNLOAD_DIR/$PACKAGE_NAME ]; then
echo "Download failed or the file does not exist. Please check your internet connection and try again."
exit 1
fi
# Extract the package
tar -xzvf $DOWNLOAD_DIR/$PACKAGE_NAME -C $DOWNLOAD_DIR
# Install Python if necessary
install_python
# Create virtual environment and activate it
python3 -m venv $DOWNLOAD_DIR/venv
source $DOWNLOAD_DIR/venv/bin/activate
# Install required Python libraries
if [ ! -f $DOWNLOAD_DIR/YAS-pedistrain-camera/requirements.txt ]; then
echo "Requirements file not found. Please ensure the package is correctly extracted."
exit 1
fi
pip install -r $DOWNLOAD_DIR/YAS-pedistrain-camera/requirements.txt
# Make the main executable script executable
if [ ! -f $DOWNLOAD_DIR/YAS-pedistrain-camera/install.sh ]; then
echo "Main executable script not found. Please ensure the package is correctly extracted."
exit 1
fi
chmod +x $DOWNLOAD_DIR/YAS-pedistrain-camera/install.sh
# Create a systemd service
sudo bash -c "cat <<EOF > /etc/systemd/system/$SERVICE_NAME.service
[Unit]
Description=YAS-pedistrain-camera Service
After=network.target
[Service]
ExecStart=$DOWNLOAD_DIR/venv/bin/python $DOWNLOAD_DIR/YAS-pedistrain-camera/install.sh
WorkingDirectory=$DOWNLOAD_DIR
Restart=always
User=$(whoami)
[Install]
WantedBy=multi-user.target
EOF"
sudo systemctl daemon-reload
sudo systemctl enable $SERVICE_NAME
sudo systemctl start $SERVICE_NAME
echo "Installation and service setup complete!"
# tar -czf my_app.tar.gz /path/to/your/app/files /path/to/your/config.json install.sh
# wget https://example.com/my_app.tar.gz && tar -xzf my_app.tar.gz && sudo ./install.sh
# cd /home/hany/Desktop/Work/Finished/Deployment/ped/ped/pedstrain_service/
# tar -czf package.tar.gz /home/hany/Desktop/Work/Finished/Deployment/ped/ped/pedstrain_service/ /home/hany/Desktop/Work/Finished/Deployment/ped/ped/pedstrain_service/config.json /home/hany/Desktop/Work/Finished/Deployment/ped/ped/pedstrain_service/install.sh