AutoInstaller is a Django-based web application designed to manage and install software applications. It features a frontend for browsing and purchasing apps with WeChat payment integration, an admin interface for app management, and an API to trigger installations programmatically. On Windows, installations are executed via a custom protocol (myapp://
) handled by LocalApp.exe
, which can be triggered from the frontend or a command-line batch file.
- App Management: Admins can upload apps with ZIP files, icons, screenshots, and installation scripts via
/management/admin/
. - WeChat Payment: Users can purchase paid apps using WeChat QR code payments.
- Frontend Installation: Click "安装" (Install) to trigger app installation via a custom protocol.
- API Installation: Use
install_app <app_name>
in CMD to trigger installations via the API andLocalApp.exe
. - Docker Support: Deploy the server with Docker Compose.
AutoInstaller_for-company/
├── .env # Environment variables (DB, WeChat credentials)
├── AutoInstaller/
│ ├── settings.py # Django settings with .env integration
│ ├── urls.py # Root URL configuration
│ └── ...
├── Installer/ # App for user-facing features
│ ├── models.py # App model
│ ├── views.py # API and payment views
│ ├── urls.py # App-specific routes
│ └── templates/ # Frontend templates
│ └── app_detail.html
├── Management/ # Admin management app
├── docker-compose.yml # Docker Compose configuration
├── Dockerfile # Docker image definition
├── requirements.txt # Python dependencies
├── install_app.bat # Batch file for API-triggered installs
├── LocalApp.exe # Compiled installer (Windows)
└── README.md # This file
-
Server:
- Python 3.10+
- Docker (optional, for containerized deployment)
- PostgreSQL (running on
db-host
) - WeChat Merchant Account (for payments)
-
Client (Windows):
LocalApp.exe
inC:\localapp\
install_app.bat
in PATH (e.g.,C:\Users\<username>\
orC:\Windows\System32
)- Network access to
\\localhost\apps\
for installers
-
Clone the Repository
git clone https://github.com/BotirBakhtiyarov/AutoInstaller_django.git cd AutoInstaller_django
-
Create Virtual Environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install Dependencies
pip install -r requirements.txt
-
Set Up
.env
Create.env
in the project root:SECRET_KEY=your-secret-key-here DEBUG=True ALLOWED_HOSTS=localhost,127.0.0.1 # Database settings DB_NAME=app_database DB_USER=admin DB_PASSWORD=admin DB_HOST=host DB_PORT=5432 # WeChat Payment Settings WECHAT_APP_ID=your-app-id WECHAT_API_KEY=your-api-key WECHAT_MCH_ID=your-merchant-id WECHAT_MCH_CERT=Wechat_cert/cert.pem WECHAT_MCH_KEY=Wechat_cert/key.pem
-
Apply Migrations
python manage.py migrate
-
Create Superuser
python manage.py createsuperuser
-
Run Server
python manage.py runserver
- Access at
http://localhost:8000/
.
- Access at
- Build and Run
docker-compose up --build
- Apply Migrations
docker exec -it <web_container_id> python manage.py migrate docker exec -it <web_container_id> python manage.py createsuperuser
-
Place
LocalApp.exe
- Copy
LocalApp.exe
toC:\localapp\
. - Ensure it’s compiled from
install_app.py
withpsycopg2
bundled:pyinstaller --onefile --console --hidden-import=psycopg2 install_app.py -n LocalApp
- Copy
-
Register Custom Protocol
- Save as
myapp.reg
:Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\myapp] @="URL:MyApp Protocol" "URL Protocol"="" [HKEY_CLASSES_ROOT\myapp\shell] [HKEY_CLASSES_ROOT\myapp\shell\open] [HKEY_CLASSES_ROOT\myapp\shell\open\command] @="\"C:\\localapp\\LocalApp.exe\" \"%1\""
- Double-click to import.
- Save as
-
Set Up
install_app.bat
- Save in
C:\Users\<username>\install_app.bat
:@echo off setlocal EnableDelayedExpansion if "%~1"=="" ( echo Usage: %0 ^<app_name^> exit /b 1 ) set "APP_NAME=%~1" set "API_URL=http://localhost:8000/api/install/%APP_NAME%/" echo Calling API for %APP_NAME%... curl -X POST "%API_URL%" > response.json for /f "tokens=*" %%i in ('powershell -Command "Get-Content response.json | ConvertFrom-Json | Select-Object -ExpandProperty install_url"') do ( set "INSTALL_URL=%%i" ) if "!INSTALL_URL!"=="" ( echo Error: No install URL returned from API. Check response.json. type response.json exit /b 1 ) echo Triggering installation for %APP_NAME% with URL: !INSTALL_URL!... "C:\localapp\LocalApp.exe" "!INSTALL_URL!" del response.json endlocal
- Add to
PATH
:- Move to
C:\Windows\System32\
(requires admin):move C:\Users\<username>\install_app.bat C:\Windows\System32\
- Or update
PATH
:setx PATH "%PATH%;C:\Users\<username>"
- Move to
- Save in
- Browse Apps: Visit
/app/<app_name>/
to view details and purchase. - Install: Click "安装" to trigger
myapp://install/<app_name>
, launchingLocalApp.exe
.
- Command: Open CMD and run:
install_app WeChat
- Response: Triggers
LocalApp.exe
to installWeChat
from\\10.20.1.201\apps\
.
- Add Apps: Log in at
/management/admin/
to upload apps with scripts.
- API Call:
install_app <app_name>
callshttp://localhost:8000/api/install/<app_name>/
, returning{"install_url": "myapp://install/<app_name>"}
. - Batch File:
install_app.bat
extracts theinstall_url
and runsLocalApp.exe
with it. - LocalApp.exe: Fetches the script path from
app_database
and executes it from\\localhost\apps\
.
-
API Error:
- Check
debug.log
forNo App matches the given query
. - Add apps via
/management/admin/
.
- Check
-
Install Fails:
- Test:
C:\localapp\LocalApp.exe myapp://install/WeChat
. - Verify
\\localhost\apps\<script_path>
accessibility.
- Test:
-
Command Not Found:
- Ensure
install_app.bat
is inPATH
:echo %PATH%
- Ensure
-
Production:
- Set
DEBUG=False
in.env
. - Use Gunicorn:
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "AutoInstaller.wsgi:application"]
inDockerfile
. - Secure with Nginx and HTTPS.
- Set
-
Client: Distribute
LocalApp.exe
andinstall_app.bat
with instructions.
MIT License - see LICENSE for details.
- Fork the repo.
- Create a branch (
git checkout -b feature/xyz
). - Commit changes (`git commit -m "Add XYZ"').
- Push (
git push origin feature/xyz
). - Open a Pull Request.